Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp - hidden element - null to empty string

 
Anitha Krishnamurthi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have written following jsp in weblogic 8.1

<%
String sss = null;
%>
<form>
<input type="hidden" name="tx" value="<%=sss%>">
</form>
Checking Hidden null values ....

After deploying the jsp the view source shows the hidden element as
<input type="hidden" name="tx" value="">

but in websphere is shows as <input type="hidden" name="tx" value="null">


how is the null replaced with empty string in case of web logic when I am not doing any transformation.

Please help...

Thanks in Advance
Regards,
Anitha
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP compiler is doing that for you.

These days, it's better to use the features of JSP 2.0.
The newer JSP EL expressions ${sss} will automatically convert nulls to empty strings for you.

Note: The Jasper compiler used to do this with JSP expressions but stopped when Tomcat 5.0 came out. I'm not sure but I think Weblogic uses Jasper as its JSP compiler.
 
Anitha Krishnamurthi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your response. I found that the following code in weblogic.xml is doing this

<jsp-param>
<param-name>printNulls</param-name>
<param-value>false</param-value>
</jsp-param>

Is there anyway to do the same in Websphere. I am migrating my application from Weblogic to Websphere.

Thanks in Advance

Regards,
Anitha
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure but I'll move this to our Websphere forum for you.
 
Anitha Krishnamurthi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben.. Hoping to get a solution soon....

Regards,
Anitha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic