Since the parameter is a string so to check it against a blank value, the code should be:-

if(param.equals(""))

and not if(param=="") as this code will check the param object and not its value.

Charu

>From: "Amrinder, Arora (Meritage)" <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: checking value of parameter from jsp
>Date: Wed, 28 Nov 2001 15:16:42 -0500
>
>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
>


Get your FREE download of MSN Explorer at http://explorer.msn.com
___________________________________________________________________________ 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