tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Haynes" <>
Subject RE: [OT]Re: <sql:param> null weirdness
Date Tue, 19 Aug 2003 08:20:19 GMT
They do say in the spec somewhere that the sql library in JSTL should only
be used in rapid prototyping and not in production code because the library
does break the considered MVC best practice of keeping the presentation
separate from the model.


-----Original Message-----
From: Marco Tedone []
Sent: 17 August 2003 09:03
To: Tag Libraries Users List
Subject: [OT]Re: <sql:param> null weirdness

Just a question which came into my mind by reading at this email. It has
been said that JSPs allow separation of roles between the web and the
business developers so that, ideally, the former should work independently
by the latter. Then, because prior to Struts-el :) some java code was
mungled within the JSP code, then Struts-el came out. I am wondering whether
an <sql:update> element as the one below, would actually separate the
front-end developer by the business developer. At the end, hasn't Struts
been invented to exhibit an handful MVC framework for web applications?


----- Original Message -----
From: "Rick Ross" <>
To: <>
Sent: Sunday, August 17, 2003 7:11 AM
Subject: <sql:param> null weirdness

I wonder if I am not understanding EL properly...

I have a form

    <input type="text" name="time" />
    <input type="submit" name="submit" />

and then a nice sql update to catch the form

    INSERT INTO myTable VALUES ( ? )
    <sql:param value="${param.time}" />

The problem comes when the form parameter is empty.  Since the actual
database field is a mySQL TIME field, there is a very big difference between
an empty string and a null.  Empty strings will be converted into '00:00:00'
in the database but nulls will just stay null (nulls are allowed and no
defaults are specified).

The sql:param tag will never return a null if there is a "time" key in the
params.  Since the form always posts the parameter, I'll always have
'&time=&somethingelse='  in my request.  <sql:param> sees this as an empty
string "", which becomes '00:00:00' in my database.

This however, works:
<sql:param><c:out value="${param.time}" /></sql:param>

I am assuming that this is an intentional thing, but I'm not sure and I'd
like to know why.




To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message