String variable=null;
1.out.println("Some String"+variable);
2.<%=variable%>
since in the first case i see "nul"l displayed and other case i see a
"blank" value.
regards
suresh
<%=variable%> evaluates the variable value as a String. It would be like out.println("Some
String" + variable.toString());
Hope this helps!
Leilani
jspwriter.println("Some String = " + variable);
and the JSP tag generates:
jspwriter.print(StringUtils.valueOf(variable));
The StringUtils.valueOf(Object obj) method looks like this:
return obj != null ? obj.toString() : "";
I would argue that it should look like this so that they are the same:
return obj != null ? obj.toString() : "null";
I would file a case with support...
Robert
<%= variable %> will result in a blank instead of 'null',
but it creates problems when porting to other containers which
do not do this, and WebLogic JspWriter implementation is not doing
what it supposed to do according to Sun's javadoc:
---
javax.servlet.jsp.JspWriter.print(String s)
Print a string. If the argument is null then the string "null" is printed.
javax.servlet.jsp.JspWriter.print(Object obj)
Print an object. The string produced by the String.valueOf(Object) method is
translated into bytes according to the platform's default character encoding,
and these bytes are written in exactly the manner of the Writer.write(int) method.
and java.lang.String.valueOf(Object obj)
Returns:
if the argument is null, then a string equal to "null"; otherwise, the value
of obj.toString() is returned.
---
> jspwriter.print(StringUtils.valueOf(variable));
> Dingo Girl wrote:
--
Dimitri
Since WLS has always printed "" instead of "null", we are not planning to fix this
in 6.1 or earlier releases. The main motivation for printing "" was to make it easier
for the JSP programmer so that they could do this:
<%= foo %>
instead of:
<%= (foo != null) ? foo : "" %>
In WLS 7.0, we have changed the default behavior to print "null" instead so as to
be strictly JSP 1.2 compliant but have added a "printNulls" element to the deployment
descriptor to allow you to revert to the old behavior.
Hope this helps,
Robert