Professional Documents
Culture Documents
Create a JSP application with a facility to (1)Login to the application (2) Register a
new user and (3) Change password for an existing user.
2.PROGRAM CODE:
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Index.html</title>
<meta charset="UTF-8">
</head>
<body>
<h1> <a href="registration.html">New Registration</a> </h1>
</body>
</html>
New Registration
Login In
Registration.html
<!DOCTYPE html>
<html>
<head>
<title>Registration Page</title>
<meta charset="UTF-8">
</head>
<body>
<h1>
Registration Page
</h1>
Name: <input type="text" id="name" name="name" placeholder="Enter your name" required> <br>
</div>
</form>
</body>
</html>
Registration Page
Name:
Phonenumber:
E-mail:
Password:
Confirm Password:
Reset submit
Login.html
<!DOCTYPE html>
<html>
<head>
<title>Login.html</title>
<meta charset="UTF-8">
</head>
<body>
<h1>Login In Page</h1>
</div>
</form>
</body>
</html>
Login In Page
E-mail:
Password:
Login
Forgot Password
Forgotpassword.html
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="forgotpassword.jsp" method="post">
<div>
Phonenumber: <input type="text" id="phonenumber" name="phonenumber">
<br>
</div>
</form>
</body>
</html>
Phonenumber:
Login
Registration.jsp
<%@page contentType="text/html" import="java.sql.*"%>
<%
String name=request.getParameter("name");
if(password.equals(confirmpassword))
{
try
{
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","AJAY","Gajula@21Amulya");
PreparedStatement ps = conn.prepareStatement("insert into registration values(?,?,?,?)");
ps.setString(1,name);
ps.setString(2,phonenumber);
ps.setString(3,email);
ps.setString(4,password);
int x=ps.executeUpdate();
if(x!=0)
{
out.print("Signup done successfully...");
}
else
{
out.print("Something went wrong...");
}
}
catch(Exception e)
{
out.println(e+" exception.");
}
}
else
{
out.println("Password not matched. ");
}
%>
Login.jsp
<%@page contentType="text/html" import="java.sql.*"%>
<%
String email = request.getParameter("email");
try
{
//response.setContentType("text/html");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","AJAY","Gajula@21Amulya");
PreparedStatement ps = conn.prepareStatement("select password from registration where email=?");
ps.setString(1,email);
ResultSet rs = ps.executeQuery();
if(rs.next())
{
if(password.equals(rs.getString(1)))
{
out.println("~~~ LOGIN SUCCESSFULLL ~~~");
}
else
{
out.println("Wrong password...");
out.println("<br><a href=\"login.html\">Try again!<a>");
}
}
else
{
}
catch(Exception e)
{
out.println(e+" exception.");
}
%>
Forgotpassword.jsp
<%@page contentType="text/html" import="java.sql.*"%>
<%
String password=request.getParameter("newpassword");
try
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","AJAY","Gajula@21Amulya");
ps.setString(1,phonenumber);
ResultSet rs = ps.executeQuery();
if(rs.next())
if(phonenumber.equals(rs.getString(1)))
else
else
catch(Exception e)
{
out.println(e+" exception.");
%>
3.Result/Output/Writing Summary:
Learning outcomes (What I have learnt):
1.
2.
3.
4.
5.
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):