Why does this code snippet put "null" string in textbox while invoking !_NEWLINE_!JSP page for the first time??
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rahul_Malhotra
Posted On:   Saturday, April 21, 2001 02:34 AM

Why does this code snippet put "null" string in textbox while invoking
JSP page for the first time??

Does this mean JSP returns string variable "null"
from request.getparameter() ?

<%
String name = request.getParameter("txtName");
%>



<%=name%>">



Re: Why does this code snippet put &quot;null&quot; string in textbox while invoking !_NEWLINE_!JSP page for the first time??

Posted By:   Anonymous  
Posted On:   Tuesday, April 24, 2001 06:39 AM

If you want to avoid this, just replace the <%=name%> by <%=(name==null?"":name)%>



Best regards,



Thierry De Leeuw

Re: Why does this code snippet put &quot;null&quot; string in textbox while invoking !_NEWLINE_!JSP page for the first time??

Posted By:   AlessandroA_Garbagnati  
Posted On:   Sunday, April 22, 2001 01:29 AM

Hi,

the string "null" it's the default value for a string when you try to print it. If you try this two lines:

String x = null;

System.out.println("X is " + x);


you will get the same result.

Re: Why does this code snippet put &quot;null&quot; string in textbox while invoking !_NEWLINE_!JSP page for the first time??

Posted By:   manoj_bhoyar  
Posted On:   Saturday, April 21, 2001 02:52 AM

hfdhgh
About | Sitemap | Contact