Hi, all! Could someone, please, help me out with this? I'm confused...

I have a servlet that generates a form.
 On submitting the form, the same servlet is called with the new parameters.
In the servlet I check if the Submit button was pressed and
 if so - call validateLogin() method to validate the user's name. (some code

is shown below). Everything worked fine when I was testing this with 
JSDK2.0 servletrunner (JDK1.1.7), but when I moved to Apache1.1.6+JServ1.0
I get errors like this: (from jserv.log file:)

 [13/07/1999 11:58:44:920 EDT] Status: 500 Internal Server Error
[13/07/1999 11:58:44:920 EDT] Servlet-Error: java.lang.NullPointerException:
null
[13/07/1999 11:58:44:920 EDT] Content-Type: text/html
[13/07/1999 11:58:44:920 EDT] Set-Cookie:
JServSessionId=3fd6e3893988feb8.2.931881524917; path=/
[13/07/1999 11:58:44:921 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)
 
Here is the relevant code:

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>");
          }
        }
        ...
    }

  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) { ... }

}

  thank you very much,
  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]

Reply via email to