WT Exp 11
WT Exp 11
Objective: Write a JSP which insert the details of the 3 or 4 users who register with the web
site by using registration form. Authenticate the user when he submits the login form using the
user's name and password from the database.
Code:
Login.html:
<html>
<body>
<tr>
<form action="auth.jsp"><table>
<tr>
</tr>
<tr>
</tr>
<tr>
<td>User Name</td>
</tr>
<tr>
<td>Password</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
</tr> </table>
/form>
</td>
</tr>
</table>
</body>
</html>
Auth.jsp:
<%@page import="java.sql.*;"%>
<html>
<head>
<title>
</title>
</head>
<body bgcolor="yellow">
<%!String uname,pwd;%>
<%
uname=request.getParameter("user"); pwd=request.getParameter("pwd");
try
Class.forName("com.mysql.cj.jdbc.Driver");
String dbUrl = "jdbc:mysql://localhost:3306/mywebsite_db";
Statement st=con.createStatement();
out.println("Authorized person");
else
out.println("UnAuthorized person");
}
con.close();
catch(Exception e){out.println(""+e);}
%>
</body>
</html>
Output