• Post Reply Bookmark Topic Watch Topic
  • New Topic

request.getParameter()  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i am passing a value in query string to another page. i am getting the value through request.getParameter().i pass null value in the query string.in if condition will be procedded if the got value is not null but the condition is executed for null value. can some one help me out.

My code
-------
jsp1
----


String notiToken = null;
<input type="hidden" name="token" value="<%=notiToken%>">



jsp2
----

String token = null;

token = request.getParameter("token");

out.println("token="+token);
if(token!=null){
out.println("token inside if="+token);
}
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry mate but I did not understand your doubt. Can you be more clear?
 
yesukannan jeyaraj
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i pass a null value in query string to another page. in that page i process a condition if the value is not null. but in my senario the condition executed for the null value.
 
Ranch Hand
Posts: 826
Chrome Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by yesukannan jeyaraj:

My code
-------
jsp1
----


String notiToken = null;
<input type="hidden" name="token" value="<%=notiToken%>">





Try this out..

I think now you understand....

Hope this helps..
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
value="<%=notiToken%>"
will not return null.
It will either pass the string "null" or an empty string.

If you want the value to be null, simply don't pass anything.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!