Hi Noah,
actually I think you fell on one of the classic java-coding-traps.

The string never compares in this way: 
           if (action == "test")
you should use 
           if (action.equals("test") == true)

Note I put the "== true" because I think it is more readable...

You can believe me, for a former C++-crack (like me) this trap
has trapped already too much.

good luck
Alexander Jesse

===============================================================

Noah Nordrum wrote:
> 
> 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]

Reply via email to