David Odmark wrote:
>
> Hey y'all,
>
> We're trying to migrate a fairly large project from the .92
> implementation of jsp to 1.0. In both cases, we are using the reference
> implementation from Sun as our platform. However, in one very important
> way, the new impl. is behaving differently than the old one, which will
> definitely impact how long it takes us to accomplish this.
>
> To wit: inside an expression tag, when the expression evaluates to null,
> the *string* "null" is now being echoed to the page. For example, this
> line in a jsp page:
>
>    <input type="hidden" name="parmName" value='<%=
> request.getParameter("someParameter") %>'>
>
> gets returned thus to the client if the expression returns null (if, for
> example, the page was called w.o. someParameter):
>
>    <input type="hidden" name="parmName" value='null'>
>
> This was definitely not how the old (.92) ref. impl behaved.
>
> Does anyone know anything about this? Is it a bug or a feature? Or is it
> implementation-specific behavior, and not a fallout of the new spec?

The JSP 1.0 spec says "Expressions are evaluated at HTTP processing time.
The value of an expression is converted to a String and inserted at the
proper position in the .jsp file." Since String.valueOf(null) returns
"null", it seems like this is the expected behavior. In order to get a
different behavior the spec would need to be extended. Someone from the
JSP team who reads this may want to comment.

But it shouldn't be too hard to handle this in your application. Just
write a simple Bean with a setRequest method and a getParameter method
that returns either the value of the request parameter or an empty string
if the parameter is null. Then use

  <%= myBean.getParameter("someParameter") %>

instead.


--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to