When I pass a value from an HTML form to a JSP page and the user hasn't typed anything into one of the text fields, how do I test that it's null? String name = request.getParameter("name"); if(name==null) if(name=="") Neither of these seem to work?! Yikes! Thanks, Drew
Joined: May 13, 2001
There I go again trying to use if(name=="") where I should be using if(name.equals("")) If I had a dime for everytime I've done that...shit! Sorry, Drew
i liked Vlad's solution to the problem but one should know, - if query param is having NO value then we will have "" as a value when we do getParameter(). - if query param is NOT there(doesn't exists) in the request then we will have null as return of getParameter() -else we will have some value. hth, maulin.
Joined: Nov 04, 2001
sorry..forgot to mention... u gotta know == is not same as equals() method. == is just a reference equality check not the content check... -maulin