File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes JSP Request Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP Request Object" Watch "JSP Request Object" New topic

JSP Request Object

Gary Guion

Joined: Jun 21, 2001
Posts: 23
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

Joined: Nov 06, 2000
Posts: 1510
I always check for null and the length of the returned parameter. What is returned (null or "") depends on the browser.
if( (email != null) && (email.length() != 0) )


So much trouble in the world -- Bob Marley
Gary Guion

Joined: Jun 21, 2001
Posts: 23
I am using the .equals method and it is working now.
I agree. Here's the link:
subject: JSP Request Object
It's not a secret anymore!