tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Ross" <rr...@stupendousman.com>
Subject <sql:param> null weirdness
Date Sun, 17 Aug 2003 06:11:58 GMT
I wonder if I am not understanding EL properly...

I have a form

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

and then a nice sql update to catch the form

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

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.

Anyone? 

Thanks,

R


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message