Google Answers Logo
View Question
 
Q: Login Servlet Can't Work!!! ( No Answer,   0 Comments )
Question  
Subject: Login Servlet Can't Work!!!
Category: Computers
Asked by: maxflo-ga
List Price: $2.00
Posted: 10 May 2003 17:05 PDT
Expires: 10 May 2003 17:29 PDT
Question ID: 202164
When I try to compile my login servlet I get the error below:

Note: LoginServlet.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.

My Login servlet is as shown below:


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;


public class LoginServlet extends HttpServlet{
  
	public void doPost(HttpServletRequest req,HttpServletResponse res)
	                              throws ServletException,IOException {
		
	res.setContentType("text/html");
	PrintWriter out =res.getWriter();


        Connection conn = null;
	ServletConfig config;
	Statement stmt=null;
     	ResultSet rs = null;
	boolean status = false;
        String wrongUser = "Invalid UserName ";
        String wrongPwd = "Invalid Password ";
	
	String userName = req.getParameter("userName");
	String password = req.getParameter("password");

        out.println("user"+userName);
        out.println("pass"+password);
                 

          
        HttpSession session = req.getSession(true);
  
        userName = userName.trim();
        password = password.trim();	        
		
        try{
           Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
           conn=DriverManager.getConnection("jdbc:odbc:mpemsdb1");
        }
       	catch(Exception  e){
            out.println("Could not open connection to DB"
+e.toString());
            e.printStackTrace();
        }
         

        try {
            stmt = conn.createStatement();
            rs= stmt.executeQuery("SELECT admin_password FROM
administrator WHERE admin_userName ='"+userName+"' ");

	   /*    
            if(rs == null)
                 res.sendRedirect("http://simt-dev.unl.ac.uk:8241/adminpage.html");
      	
            rs.next();
            if(!password.equals(rs.getString(4)))
                 res.sendRedirect("http://simt-dev.unl.ac.uk:8241/adminpage.html");
	   */


            if(rs == null){// no user with this username
                session.putValue("mpems.errormsg",wrongUser);
                res.sendRedirect("http://simt-dev.unl.ac.uk:8241/loginErrorPage.jsp");
            }
      	
            rs.next();
            if(!password.equals(rs.getString(4))){
                 session.putValue("mpems.errormsg",wrongPwd);
                 res.sendRedirect("http://simt.unl.ac.uk:8241/loginErrorPage.jsp");

            }		    
            //put values in session...
  	    
            session.putValue("mpems.user",userName);
	    session.putValue("mpems.pass",password);
 
           // if(password.equals(rs.getString(4)))
           //         session.putValue("mpems.userToEdit",userName);
  	   // status = true;
 
         

            if(password.equals(rs.getString(4)))
                 res.sendRedirect("http://simt-dev.unl.ac.uk:8241/index.jsp");
           // else
             //   res.sendRedirect("http://simt-dev.unl.ac.uk:8241/adminpage.html");

            }
            
            catch(Exception  e) { 
                session.putValue("mpems.errormsg",wrongUser);
                res.sendRedirect("http://simt-dev.unl.ac.uk:8241/loginErrorPage.jsp");
    
            }

    }//do post ends here

}



Please kindly help me out - I'd like my servlet to work.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy