Professional Documents
Culture Documents
jsp
<%--
Document : validateUser
Author : Administrator
--%>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>JSP Page</title>
</head>
<body>
<%
un=request.getParameter("username");
pw=request.getParameter("password");
try{
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/Student","root","patkar");
PreparedStatement ptst=con.prepareStatement(sql);
ptst.setString(1, un);
ptst.setString(2, pw);
ResultSet res=ptst.executeQuery();
if(res.next())
//
response.sendRedirect("index.jsp");
// out.print("hiieee");
else
out.print("Invalid User");
//response.sendRedirect("login.jsp");
}catch(Exception e)
{out.print(e);}
%>
</body>
</html>
//login.jsp
<%--
Document : login
Author : Administrator
--%>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Login</title>
</head>
<body>
<center>
<table>
<tr>
</tr>
<tr>
<td>
Enter Password :
</tr>
<tr>
<td>
</tr>
<h1></h1>
</table>
</center>
</form>
</body>
</html>
For invalid user