JSTL, while new to me, appears to be a good approach. I, however, just do
the following. I'm using request.getAttribute() as the source of my
possibly-null string, as that's where it seems to arise most often for me.
String sParam = request.getAttribute("param");
if (sParam == null) sParam = "";
That one quick, easy line will prevent your variable from ever being null
when you need it. Just throw it in after you retrieve the String from its
source.
-Jake
Tim Funk wrote:
> There is no way. For those of you playing at home, here is what is going
> on. Consider the snippet:
> <%
> String moreCowbell = null
> %>
> I need: <%=moreCowbell%>
>
> The results for weblogic is:
> I need:
>
> The result for tomcat (and many other servlet engines) is:
> I need: null
>
> The code which is generated looks similar to this:
> out.print(com.weblogic.SomeWackyUtil.toStringUtil(moreCowbell));
>
> Tomcat does this:
> out.print(moreCowbell);
>
>
> Where com.weblogic.SomeWackyUtil.toStringUtil is a utility that converts
> nulls to nothing.
>
> In a nutshell - to get around this - don't print nulls. A much better
> way to get around this is to use JSTL. JSTL will not print "null" in the
> presence of a null. And JSTL is much easier on the eyes than <%= %>
>
> -Tim
>
> Albert Sidelnik wrote:
>> I am in need of some help with an issue that I've encountered. I have an
>> application that's currently running on Weblogic 6.1 and I'm trying to
>> port the application to JBoss w/ Tomcat 4.1.18. The problem is that on
>> my JSP pages, the word "null" is being displayed on the page. Weblogic
>> treated these as blank strings (""), but when I am trying to switch to
>> Jboss the word "null" is being printed. We had the same problem when
>> upgrading to Weblogic 7 from Weblogic 6.1, but they provided a fix that
>> when pre-compiling the JSP's, we could set a "NoPrintNulls" flag that
>> would basically use an empty string in place of the "null" string. Is
>> there a similar fix in Tomcat? I am sure that other people have had this
>> issue, but I have not been able to find anything in the other user
>> forums. I know this "feature" was changed as part of the JSP 1.2
>> specification, but I'm really hoping there might be a way to revert back
>> just like weblogic allows you. Thanks
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]