Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Request Object

 
Gary Guion
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I call request.getParameter to get the value of a field from the calling page, if that field was blank then is the string returned "" (empty)? I am using a conditional like
if(name != "" && email != "") and even if I leave the fields blank it still enters the if and never sees the else. Why?
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I always check for null and the length of the returned parameter. What is returned (null or "") depends on the browser.
EX:
if( (email != null) && (email.length() != 0) )

Bosun
 
Gary Guion
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the .equals method and it is working now.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic