Kwan,

Your string could be all blanks.

try testing like:

String name = request.getParameter ("name");
if ((name == null) || (name.trim()==""))

--amrinder

_____________________________________________
From: Kwan, William [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 28, 2001 2:54 PM
To: [EMAIL PROTECTED]
Subject: checking value of parameter from jsp


Hi all,

I'm passing information from a html page to a servlet.

Here is some code:

String param = request.getParameter("name");
if (param == null) sqlstr = "Select * from name";
else sqlstr ="Select * from name where fname like '"+param + "'";

and

if (param == "")  sqlstr = "Select * from name";
else sqlstr ="Select * from name where fname like '"+param + "'";

These both dont detect the blank value when they click submit on the jsp
page.  It always goes to the else part.

Am I doing something wrong??  Is there another way to detect if they entered
any data in the field on the form??

thanks,
Will

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to