Hi !!
 
I think you should try like this :
 
 
if ( req.getParameterValues("hname")==null) {
                                                                              machine=false;
                                                                              }
 
if(machine) {
                     
                     string name= req.getParameterValues("hname")[0];
 
                   }
 
 
Hope it helps,
 
            Best wishes,
                                       Andras.
 
-----Original Message-----
From: Miriam <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Thursday, May 06, 1999 11:18 AM
Subject: weird getParameter behavior

>  I am trying to determine if a page was called with a parameter or not,
>and display output based on this, however, java is complaining about a
>NullPointerException,
>
> here is what I am trying to do:
>
>        // Did we get called with a machine name?
>        boolean machine=true;
>        if (req.getParameter("hname")==null)
>           machine=false;
>
>        if (machine) {
>
>        // blah blah big table
>        }
>        else {
>
>        // blah blah a different table
>
>        }
>
> when I use getParameter the url ~/update.jhtml?hname=something works
> but ~/update.jhtml does not.
>
> Conversely, when I use getParameterValues the url ~/update.jhtml
>works,   but ~/update.jhtml?hname=something does not..
>
> the error looks like:
>
>
> !-- java.lang.NullPointerException
>        at org.apache.jservssi.ServletInfoRequest.getParameter(Compiled Code)
>        at MachineUpdateServ.service(Compiled Code)
>        at javax.servlet.http.HttpServlet.service(Compiled Code)
>        at org.apache.jservssi.ServletInfoRequest.runServlet(Compiled Code)
>        at org.apache.jservssi.JServSSI.interpretPage(Compiled Code)
>        at org.apache.jservssi.JServSSI.doGet(Compiled Code)
>        at javax.servlet.http.HttpServlet.service(Compiled Code)
>        at javax.servlet.http.HttpServlet.service(Compiled Code)
>        at org.apache.jserv.JServConnection.run(Compiled Code)
>        at java.lang.Thread.run(Compiled Code)
>-->
>
> -Miriam
>
>___________________________________________________________________________
>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