Thanks a lot Matthias. I used the way you suggested
and it is working now. Thanks. cool.

roy


--- Matthias Carlsson
<[EMAIL PROTECTED]> wrote:
> Your code isn't safe. If "go" isn't specified in the
> query string, you
> will be calling equals() on a null object. That's
> why you get a
> NullPointerException.
> You can fix this by using the code below:
>
> String go = request.getParameter("go");
> if ("tips".equals(go)) {
>         showTips(response);
> }
>
> This code won't throw a NullPointerException if go
> is null. You could also
> do
> something like this:
>
> if (go != null && go.equals("tips")) {
>
>
> [ Matthias Carlsson ]
> [ Programmer (Java, XML/XSL, CGI/Perl, HTML/JS) ] [
> Web Designer ]
> [ E-Mail : [EMAIL PROTECTED] ] [
> ICQ: 1430647 ]
>
> > -----Ursprungligt meddelande-----
> > Fran: A mailing list for discussion about Sun
> Microsystem's Java Servlet
> > API Technology.
> [mailto:[EMAIL PROTECTED]]For roy woods
> > Skickat: den 8 april 2001 11:38
> > Till: [EMAIL PROTECTED]
> > Amne: Re: Query String Value is returning null.
> why?
> >
> >
> > I am simply using this:
> >
> > String go = req.getParameter("go");
> > if(go.equals("tips")){
> > showTips(res);
> > }
> >
> > and I get the java.lang.NullPointerException on
> the
> > browser. Could you show me how you do it in simple
> > code?
> >
> > roy
> >
> >
> > --- Robert Nicholson <[EMAIL PROTECTED]> wrote:
> > > What happens when you iterate over the requests
> > > parameter list. What's
> > > there? What to does QueryHash's keyEnumerator
> show?
> > >
> > > > -----Original Message-----
> > > > From: A mailing list for discussion about Sun
> > > Microsystem's Java Servlet
> > > > API Technology.
> > > [mailto:[EMAIL PROTECTED]]On Behalf
> Of
> > > roy
> > > > woods
> > > > Sent: Saturday, April 07, 2001 12:34 PM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Query String Value is returning null.
> > > why?
> > > >
> > > >
> > > > Hi all
> > > >
> > > > In my Servlet I have a link like this:
> > > > http://localhost/servlet/Library?go=tips But
> the
> > > Query
> > > > string value is ignored. I mean, go has no
> value.
> > > > and the parameter go returns null. On my
> browser I
> > > > therefore get
> > > >
> > > > Error: 500
> > > >
> > > > Location: /servlet/Library
> > > >
> > > > Internal Servlet Error:
> > > >
> > > > java.lang.NullPointerException:
> > > >
> > > > How can I get the query string values?
> > > >
> > > > Thanks in advance
> > > >
> > > > roy
> > > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get email at your own domain with Yahoo! Mail.
> > http://personal.mail.yahoo.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
> >
>
>
___________________________________________________________________________
> 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


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.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