Sun Feb 10, 2013 5:52 am
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class LoginEx extends HttpServlet{
Connection conn;
public void init(ServletConfig s) throws ServletException
{
try
{
System.out.println("hello1");
ServletContext sc=getServletContext();
System.out.println("hello1");
String st=sc.getInitParameter("dbclass");
Class.forName(st);
conn = DriverManager.getConnection(sc.getInitParameter("dbconn"),sc.getInitParameter("dbuser"),sc.getInitParameter("dbpass"));
}
catch(Exception cn)
{
System.out.println("error"+cn);throw new ServletException();
}
}
protected void doPost(HttpServletRequest req,HttpServletResponse resp)throws ServletException,IOException
{
resp.setContentType("text/html");
PrintWriter pw = resp.getWriter();
String n=req.getParameter("name");
String p=req.getParameter("pass");
try{
Statement st=conn.createStatement();
ResultSet rs= st.executeQuery("select * from login where ename="+n+"and pass="+p);
while(rs.next())
{
pw.println("<html><body>welcome</body></html>");
}
}
catch(Exception e){
System.out.println("error"+e);
}
pw.close();
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.