You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Rick Ross <rr...@stupendousman.com> on 2003/08/17 08:11:58 UTC

null weirdness

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


Re: [OT]Re: null weirdness

Posted by Rick Ross <rr...@stupendousman.com>.
Yes, that is current dogma amongst most developers.  I use a different
approach.

The question remains... was this done intentionally?

R
----- Original Message ----- 
From: "Marco Tedone" <mt...@jemos.org>
To: "Tag Libraries Users List" <ta...@jakarta.apache.org>
Sent: Sunday, August 17, 2003 1:03 AM
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?
>
> Regards,
>
> Marco
> ----- Original Message ----- 
> From: "Rick Ross" <rr...@stupendousman.com>
> To: <ta...@jakarta.apache.org>
> 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
>
> <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
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>


Re: [OT]Re: null weirdness

Posted by Rick Ross <rr...@stupendousman.com>.
Yes, that is current dogma amongst most developers.  I use a different
approach.

The question remains... was this done intentionally?

R
----- Original Message ----- 
From: "Marco Tedone" <mt...@jemos.org>
To: "Tag Libraries Users List" <ta...@jakarta.apache.org>
Sent: Sunday, August 17, 2003 1:03 AM
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?
>
> Regards,
>
> Marco
> ----- Original Message ----- 
> From: "Rick Ross" <rr...@stupendousman.com>
> To: <ta...@jakarta.apache.org>
> 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
>
> <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
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


RE: [OT]Re: null weirdness

Posted by Mark Galbreath <ma...@qat.com>.
What type of application do you have in mind..."hello world?"

Mark

-----Original Message-----
From: Rick Ross [mailto:rross@stupendousman.com] 
Sent: Tuesday, August 19, 2003 12:52 PM
To: Tag Libraries Users List
Subject: Re: [OT]Re: <sql:param> null weirdness


Well, firstly I don't beleive that every application should apply the MVC
pattern/practice.  But even if you did, there is no reason you couldn't
apply it within JSP/JSTL itself.  In JSP 2 you can create your own tags from
JSP fragments.

R
----- Original Message ----- 
From: "Daniel Haynes" <da...@btinternet.com>
To: "Tag Libraries Users List" <ta...@jakarta.apache.org>
Sent: Tuesday, August 19, 2003 1:20 AM
Subject: RE: [OT]Re: <sql:param> null weirdness


> 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.
>
> dan
>
> -----Original Message-----
> From: Marco Tedone [mailto:mtedone@jemos.org]
> 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?
>
> Regards,
>
> Marco
> ----- Original Message -----
> From: "Rick Ross" <rr...@stupendousman.com>
> To: <ta...@jakarta.apache.org>
> 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
>
> <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
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org




RE: [OT]Re: null weirdness

Posted by Mark Galbreath <ma...@qat.com>.
What type of application do you have in mind..."hello world?"

Mark

-----Original Message-----
From: Rick Ross [mailto:rross@stupendousman.com] 
Sent: Tuesday, August 19, 2003 12:52 PM
To: Tag Libraries Users List
Subject: Re: [OT]Re: <sql:param> null weirdness


Well, firstly I don't beleive that every application should apply the MVC
pattern/practice.  But even if you did, there is no reason you couldn't
apply it within JSP/JSTL itself.  In JSP 2 you can create your own tags from
JSP fragments.

R
----- Original Message ----- 
From: "Daniel Haynes" <da...@btinternet.com>
To: "Tag Libraries Users List" <ta...@jakarta.apache.org>
Sent: Tuesday, August 19, 2003 1:20 AM
Subject: RE: [OT]Re: <sql:param> null weirdness


> 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.
>
> dan
>
> -----Original Message-----
> From: Marco Tedone [mailto:mtedone@jemos.org]
> 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?
>
> Regards,
>
> Marco
> ----- Original Message -----
> From: "Rick Ross" <rr...@stupendousman.com>
> To: <ta...@jakarta.apache.org>
> 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
>
> <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
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: [OT]Re: null weirdness

Posted by Rick Ross <rr...@stupendousman.com>.
Well, firstly I don't beleive that every application should apply the MVC
pattern/practice.  But even if you did, there is no reason you couldn't
apply it within JSP/JSTL itself.  In JSP 2 you can create your own tags from
JSP fragments.

R
----- Original Message ----- 
From: "Daniel Haynes" <da...@btinternet.com>
To: "Tag Libraries Users List" <ta...@jakarta.apache.org>
Sent: Tuesday, August 19, 2003 1:20 AM
Subject: RE: [OT]Re: <sql:param> null weirdness


> 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.
>
> dan
>
> -----Original Message-----
> From: Marco Tedone [mailto:mtedone@jemos.org]
> 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?
>
> Regards,
>
> Marco
> ----- Original Message -----
> From: "Rick Ross" <rr...@stupendousman.com>
> To: <ta...@jakarta.apache.org>
> 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
>
> <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
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: [OT]Re: null weirdness

Posted by Rick Ross <rr...@stupendousman.com>.
Well, firstly I don't beleive that every application should apply the MVC
pattern/practice.  But even if you did, there is no reason you couldn't
apply it within JSP/JSTL itself.  In JSP 2 you can create your own tags from
JSP fragments.

R
----- Original Message ----- 
From: "Daniel Haynes" <da...@btinternet.com>
To: "Tag Libraries Users List" <ta...@jakarta.apache.org>
Sent: Tuesday, August 19, 2003 1:20 AM
Subject: RE: [OT]Re: <sql:param> null weirdness


> 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.
>
> dan
>
> -----Original Message-----
> From: Marco Tedone [mailto:mtedone@jemos.org]
> 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?
>
> Regards,
>
> Marco
> ----- Original Message -----
> From: "Rick Ross" <rr...@stupendousman.com>
> To: <ta...@jakarta.apache.org>
> 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
>
> <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
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>


RE: [OT]Re: null weirdness

Posted by Daniel Haynes <da...@btinternet.com>.
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.

dan

-----Original Message-----
From: Marco Tedone [mailto:mtedone@jemos.org]
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?

Regards,

Marco
----- Original Message -----
From: "Rick Ross" <rr...@stupendousman.com>
To: <ta...@jakarta.apache.org>
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

<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





---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


RE: [OT]Re: null weirdness

Posted by Daniel Haynes <da...@btinternet.com>.
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.

dan

-----Original Message-----
From: Marco Tedone [mailto:mtedone@jemos.org]
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?

Regards,

Marco
----- Original Message -----
From: "Rick Ross" <rr...@stupendousman.com>
To: <ta...@jakarta.apache.org>
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

<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





---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


[OT]Re: null weirdness

Posted by Marco Tedone <mt...@jemos.org>.
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?

Regards,

Marco
----- Original Message ----- 
From: "Rick Ross" <rr...@stupendousman.com>
To: <ta...@jakarta.apache.org>
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

<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





---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


[OT]Re: null weirdness

Posted by Marco Tedone <mt...@jemos.org>.
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?

Regards,

Marco
----- Original Message ----- 
From: "Rick Ross" <rr...@stupendousman.com>
To: <ta...@jakarta.apache.org>
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

<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