//plz solve this prblm
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
/**
*
* @author Windows 7
*/
@WebServlet(name = "login", urlPatterns = {"/login"})
public class login extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbcdbc:yashdsn","", "");
Statement stmt=con.createStatement();
String str="select * from users_detail";
ResultSet rs=stmt.executeQuery(str);
String un=rs.getString("usern");
String pw=rs.getString("pwrd");
while(rs.next())
{
if(un.equals(request.getParameter("usname")))
{
if(pw.equals(request.getParameter("pwd")))
{
out.println("<font color=green font=8>Welcome.. "+un+"</font>");
break;
}
}
}
out.println("<font color=red font=8>Invalid userid/password... </font>");
stmt.close();
con.close();
}catch(Exception e){
out.println("<font color=red >Error....:"+e.getMessage()+"</font>");
} finally {
out.close();
}
}