I'm guessing its a NullPointerException: if the parameter "error" doesn't
exist, request.getParameter() will return NULL.  Trying to then do a
.compareTo() on it will cause an Exception.

try
String strError = request.getParameter("error");
if (LOGIN.equals(strError))

BTW: doing an out.println(strError) will likely show "null". You should
default strError to an empty string ("") and set it only if
request.getParameter does not return null, then do your comparison:
String strError = "";
if (request.getParameter("error") != null)
{
    strError = request.getParameter("error");
    if (LOGIN.equals(strError)) strError += "::";
}
out.println(strError);

Lance

----- Original Message -----
From: David Markert <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 19, 2000 8:19 PM
Subject: String Compares in JSP


> Anybody out there run into a problem with string compares in JSP?  I'm
using
> JRun 2.3 build 153.  I've executed the following code in a class with no
> problem, but inside a JSP I get an error (which I don't know what it is
> because the exception isn't being thrown correctly).
>
> <html>
> <head>
> <title>Login Page</title>
> </head>
> <%@ page language="java" import="java.util.*, java.sql.*, java.lang.*"
%>
> <%!
>    String strError;
>    static String LOGIN = "login";
> %>
> <%
>
> // Following code is for debugging purposes - doesn't work at the moment
>   String strError = request.getParameter("error");
>   if (strError.compareTo( "login" ) == 0)
>   {
>    out.println(strError + "::");
>   }
> out.println(strError);
> %>
> <body>

===========================================================================
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