hello,

       I am using jakarta-tomcat-3.2 with apache
1.3.12.while running my program with html and servlet
it is generating  an error log dialog box and tomcat
is getting shutdown automatically.while registering a
new user ,it is working fine(which is commented in
program ) but when i am validating for user ,it is
working fine but after getting the result it is
generating an error log dialog box and tomcat is
getting terminated .i am sending the full program and
attaching the error log dialog box with it.any
suggestions in this regard will be appreciated.
uruj                                                    


package com.bodhtree.espeak.BT3C.login;
//java Io Classes
import java.io.PrintWriter;
import java.io.IOException;

//java util Classes
import java.util.Hashtable;
import java.util.Enumeration;

//javax http Classes
import javax.servlet.http.HttpSession;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;

public class ValidationServlet extends HttpServlet
{

 public void service(HttpServletRequest
req,HttpServletResponse res) throws
                                                                                       
                                                 IOException
 {

         PrintWriter out=res.getWriter();
         HttpSession mysession = req.getSession(true);
         String username= req.getParameter("username");
         System.out.println(username);
         String password= req.getParameter("password");
         System.out.println(password);
         String nickname= req.getParameter("nickname");
         System.out.println(nickname);
         if(nickname==null)
         {

           try
           {
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
             Connection con =
DriverManager.getConnection("jdbc:odbc:3C");
             System.out.println("Connected to database");
             PreparedStatement psq =
con.prepareStatement("SELECT username FROM usertable
WHERE password='"+password+"'");
             System.out.println("after preparedStatement");
             ResultSet rs = psq.executeQuery();
             System.out.println("############### The
Resultset is ##############"+rs);
             if(rs.next()==false)
             {
               con.close();
               System.out.println("Before closing the
connection");
                  
res.sendRedirect("/bt3c/UserRegistration.html");
             }
             else
             {
                   String user=rs.getString("username");
                   mysession.putValue("username",username);
                   String
str=(String)mysession.getValue("username");
                   System.out.println("Has put the value into the
session"+user);
               con.close();
               res.sendRedirect("/bt3c/CommunityHtml.html");
             }
           }// END OF try BLOCK
           catch(Exception e)
           {
             e.printStackTrace();
           }
    }
    /*try
    {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          Connection cons =
DriverManager.getConnection("jdbc:odbc:3C");
          System.out.println("Connected to database");
          String sql= "INSERT INTO
usertable(username,password,nickname) VALUES (?,?,?)";
          PreparedStatement prst =
cons.prepareStatement(sql);
          prst.setString(1,username);
          prst.setString(2,password);
          prst.setString(3,nickname);
          prst.executeUpdate();
          System.out.println("Inserted values");
          cons.close();
          System.out.println("Connection closed");
          mysession.putValue("username",username);

    }catch(Exception e)
    {
          e.printStackTrace();
    }*/
  }
}


 

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

<<inline: error.jpg>>

Reply via email to