Looks to me like you fell into the same trap I have a couple of times, which
is that using == on strings doesn't compare strings, only their memory
addresses. Try changing the 'action == "test"' statement (and the others
that look similar) to 'action.equals("test")'.

Note that you have an if statement that tests to see if action contains a
null string ("") *before* is tests to see if it is null. Asking for a null
pointer exception...

Pete Ford
Lufkin TX

-----Original Message-----
From: Noah Nordrum <[EMAIL PROTECTED]>
To: Java Apache Users <[EMAIL PROTECTED]>
Date: Monday, May 03, 1999 4:05 PM
Subject: Really lame problem that is messing me up.


>It might be that I am VERY tired and sick, but I can't figure out why
>this isn't working.
>It seems that if I go to
>"http://localhost:8080/servlets/WebStore?action=test"
>shouldn't the following code produce a page that says "BILL GATES
>BLOWS"?
>When I do this with no arguments it creates the MainPage, but if I do it
>with
>arguments(?action=test) it produces a page that says "test".
>
>This is really messing me up right now.
>Unfortunatly I think I can't rationally blame this on M$.
>
>Thanks in advance.
>Linux 2.0.36
>Apache 1.3.6
>JServ 1.0b3
>JSDK2.0
>JDK1.2
>--
>   public void service(HttpServletRequest req, HttpServletResponse res)
>        throws ServletException, IOException
>    {
>        res.setContentType("text/html");
>        PrintWriter out = res.getWriter();
>
>        String action = req.getParameter("action");
>        if (action == "" || action == null)
>        {
>            new MainPage(out);
>        }
>        else if (action == "test")
>        {
>            out.println("<HTML><BODY>BILL GATES BLOWS</BODY></HTML>");
>        }
>        else
>        {
>            out.println("<HTML><BODY>" + action + "</BODY></HTML>");
>        }
>
>
>--
>  ==============================================================
>  Noah Nordrum
>  [EMAIL PROTECTED]
>  http://www.newfrenchbakery.com/
>  2:54pm  up 130 days 20:05 hours
>  ==============================================================
>
>
>
>
>----------------------------------------------------------------
>To subscribe:        [EMAIL PROTECTED]
>To unsubscribe:      [EMAIL PROTECTED]
>READ THE FAQ!!!!     <http://java.apache.org/faq/>
>Archives and Other:  <http://java.apache.org/main/mail.html/>
>Problems?:           [EMAIL PROTECTED]
>
>



----------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
READ THE FAQ!!!!     <http://java.apache.org/faq/>
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to