On 27 Mar 00, at 17:30, Divya M A wrote:

> Thanx a lot for the help.
> As suggested, I used 'if (request.getParameter("val") != null &&
> request.getParameter("val").equals("1"))' and it works beautifully. Wonder
> what else here(JSP/Java)  is very different from the other programming
> languages!?!
>
This is Java and not specific to JSP. The reason that you have to
use 2 different methods to check for a condition like this is that in
Java everything is an Object. The 'request.getParameter("val") !=
null' checks to see if the String object returned from getParameter
is null or not. The 'request.getParameter("val").equals("1"))' calls
the String's object equals() method to determine if your value
matches the contents of the String.

Things like this can screw you up in the beginning, in particular if
you're coming from another language (I spend most of my days
programming in Perl and Java, so imagine the fun I have ;).

If you're not familiar with these constructs, grab a good reference
like Java in a Nutshell or the Java Almnac.

Mark
> ----- Original Message -----
> From: Mike McKechnie <[EMAIL PROTECTED]>
> To: Divya M A <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Monday, March 27, 2000 4:55 PM
> Subject: Re: Using query string values in JSP
>
>
> > >  if (request.getParameter("val") == "1")
> >
> > In Java, the '==' operator does an identity comparison -- that is, two
> > object references are equal only if they refer to the same object.
> >
> > To lexically compare two strings, do something like:
> >
> > if (request.getParameter("val") != null &&
> > request.getParameter("val").equals("1"))
> > {
> > ...
> > }
> >
> >
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to