Practical 4
Practical 4
Index.html
Enter Username:
Enter Password:
Re-Enter Password:
Enter Email:
Enter Country:
Reset Register
<html>
<form action="reg.jsp" >
Enter Username: <input type="text" name="t1"><br>
Enter Password: <input type="password" name="t2"><br>
Re-Enter Password: <input type="password" name="t3"><br>
Enter Email: <input type="text" name="t4"> <br>
Enter Country: <input type="text" name="t5"> <br>
<input type="reset"> <input type="submit" value="Register">
</form>
</html>
Creating a jsp page having name reg.jsp
reg.jsp
<html>
<body>
<%
String uname=request.getParameter("t1");
String pass1=request.getParameter("t2");
String pass2=request.getParameter("t3");
String email=request.getParameter("t4");
String country=request.getParameter("t5");
if(pass1.equals(pass2))
try
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student1","admin"
,"nilam");
pst.setString(1,uname);
pst.setString(2,pass1);
pst.setString(3,pass2);
pst.setString(4,email);
pst.setString(5,country);
int row=pst.executeUpdate();
if(row==1)
else
out.println("Registration Failed.....");
%>
<jsp:include page="index.html"></jsp:include>
<%
catch(Exception e)
out.println(e);
else
{
out.println("Password Mismatch....");
%>
<jsp:include page="index.html"></jsp:include>
<%
%>
</body>
</html>
Login.html
Enter Username:
Enter Password:
Reset login
<html>
<form action="log.jsp">
</form>
</html>
<!DOCTYPE html>
<html>
<body>
<%
String uname=request.getParameter("t1");
String pass1=request.getParameter("t2");
try
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student1","admin"
,"nilam");
pst.setString(1,uname);
ResultSet rs=pst.executeQuery();
if(rs.next())
if(pass1.equals(rs.getString(1)))
else
<%
catch(Exception e)
out.println(e);
%>
</body>
</html>
Output