I do appreciate your patience with me - this is my first week with
Apache/Jserv... :-) Thanks to everybody who responded!
> > Does it mean that servletrunner and JServ handle exceptions
> differently? I
> > guess I'm wondering why didn't servletrunner catch that NPE
> before...
>
> no, of course they don't handle exceptions differently this
> IS java. one
> question...what version of servletrunner were you using? if it is jsdk
> 2.1.x, then you should be using 2.0.x because apache jserv
> only supports
> that.
>
I did work with JSDK2.0 (JDK1.1.7) on Solaris2.6.
> > Funny thing - after I recompiled the servlet with -debug
> option, the class
> > couldn't be found anymore - I've got 404 Not Found error...
>
>It's probably a problem with your classpath. You probably didn't
>add the classes of your database driver in the wrapper.classpath
>variable of the jserv.properties file.
>Benoit.
I think I have all classes in wrapper.classpath, and how come that when I
compile without -debug it does find all classes??? Does it mean that -debug
option chnage the $CLASSPATH somhow???
> i don't know and you haven't given any useful debugging
> information for us
> to help you with. sounds like your configuration is screwed
> up or something.
>
> -jon
>
Recompiling with -debug option didn't add anything to the jserv.log file
(I still have 'Compiled Code', not line numbers). Can debugging information
go to some other place? Though in my jserv.properties file I explicitly put:
log.file=/usr/local/apache/etc/jserv.log
Anyway, here is what I get in jserv.log after my LoginScreen servlet
compiled with -debug option:
[13/07/1999 16:37:34:438 EDT] Sending response headers.
[13/07/1999 16:37:34:439 EDT] Status: 404 Not Found
[13/07/1999 16:37:34:439 EDT] Servlet-Error: NoClassDefFoundError:
LoginScreen
If I compile without -debug, I can run the servlet without parameters, as:
http://idsdevel2/production/login
but if I run it with parameters
http://idsdevel2/production/login?userid=ids&submit=OK
I get the error:
[13/07/1999 16:45:57:313 EDT] Status: 500 Internal Server Error
[13/07/1999 16:45:57:313 EDT] Servlet-Error: java.lang.NullPointerException:
null
[13/07/1999 16:45:57:313 EDT] Content-Type: text/html
[13/07/1999 16:45:57:314 EDT] java.lang.NullPointerException
at LoginScreen.validateLogin(Compiled Code)
at LoginScreen.doPost(Compiled Code)
at LoginScreen.doGet(Compiled Code)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at org.apache.jserv.JServConnection.processRequest(Compiled Code)
at org.apache.jserv.JServConnection.run(Compiled Code)
at java.lang.Thread.run(Compiled Code)
It seems like it chokes on req.getParameter("userid"), but why? In
servletrunner it worked... But I repete myself, I guess :-)
And here is my code again, if you are not bored yet:
public class LoginScreen extends HttpServlet
{ ...
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
...
HttpSession session = req.getSession(true);
String userid = req.getParameter("userid");
String submit = req.getParameter("submit");
if ( submit != null ) {
if ( (userid != null) && !userid.equals(" ")
&& validateLogin(session, userid)) {
toClient.println("<HTML><BODY>Login success!
</BODY></HTML>");
}
else {
toClient.println("<HTML><BODY> Login failed</BODY></HTML>");
}
}
else {
toClient.println("<HTML><HEAD><BODY>");
toClient.println("<FORM NAME=\"login\"" +
"ACTION=\"http://idsdevel2/production/login\" METOD=POST>");
toClient.println("User ID:<INPUT TYPE=\"text\" NAME=\"userid\"
SIZE=10>\n");
toClient.print("<INPUT TYPE=\"submit\" NAME=\"submit\"
VALUE=\"OK\">");
toClient.println("</FORM></BODY></HTML>");
}
...
}
private boolean validateLogin(HttpSession session, String userid) {
String user_name = null;
Statement select_st;
String query = "select user_name from log_table where userid = '" +
userid.toUpperCase().trim() + "'";
try {
select_st = con.createStatement();
ResultSet rs = select_st.executeQuery(query);
if ( rs.next() ) {
session.putValue("userid", userid);
user_name = rs.getString("user_name");
session.putValue("user_name", user_name);
} else
return false;
rs.close();
select_st.close();
return true;
}
catch (SQLException sqe){ ... }
catch (IllegalStateException e) { ... }
}
thanks a lot!
Marina
--
--------------------------------------------------------------
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]