0% found this document useful (0 votes)
22 views8 pages

JSP User Registration and Login App

The document outlines the creation of a registration and login JSP application using JDBC for user authentication. It includes HTML forms for user registration and login, as well as JSP code for handling user input and database interactions. The application checks for password matches during registration and validates user credentials during login, providing appropriate feedback for each action.

Uploaded by

fannyskylark2003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views8 pages

JSP User Registration and Login App

The document outlines the creation of a registration and login JSP application using JDBC for user authentication. It includes HTML forms for user registration and login, as well as JSP code for handling user input and database interactions. The application checks for password matches during registration and validates user credentials during login, providing appropriate feedback for each action.

Uploaded by

fannyskylark2003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Practical 4

c) Create a registration and login JSP application to


register and authenticate the user based on username
and password using JDBC.

[Link]
Enter Username:
Enter Password:
Re-Enter Password:
Enter Email:
Enter Country:
Reset Register

<html>
<form action="[Link]" >
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 [Link]

[Link]

<%@page contentType="text/html" pageEncoding="UTF-8" import="[Link].*"%>

<html>

<body>

<%

String uname=[Link]("t1");

String pass1=[Link]("t2");

String pass2=[Link]("t3");

String email=[Link]("t4");

String country=[Link]("t5");

if([Link](pass2))

try

[Link]("[Link]");

Connection
con=[Link]("jdbc:mysql://localhost:3306/student1","admin"
,"nilam");

PreparedStatement pst=[Link]("insert into info values(?,?,?,?,?)");

[Link](1,uname);

[Link](2,pass1);
[Link](3,pass2);

[Link](4,email);

[Link](5,country);

int row=[Link]();

if(row==1)

[Link]("Registration successfully done......");

else

[Link]("Registration Failed.....");

%>

<jsp:include page="[Link]"></jsp:include>

<%

catch(Exception e)

[Link](e);

else

{
[Link]("Password Mismatch....");

%>

<jsp:include page="[Link]"></jsp:include>

<%

%>

</body>

</html>

[Link]
Enter Username:
Enter Password:
Reset login

<html>

<form action="[Link]">

Enter Username: <input type="text" name="t1"><br>

Enter Password: <input type="password" name="t2"><br>

<input type="reset"> <input type="submit" value="login">

</form>

</html>

Creating a servlet page having name [Link]


[Link]
<%@page contentType="text/html" import="[Link].*"%>

<!DOCTYPE html>

<html>

<body>

<%

String uname=[Link]("t1");

String pass1=[Link]("t2");

try

[Link]("[Link]");

Connection
con=[Link]("jdbc:mysql://localhost:3306/student1","admin"
,"nilam");

PreparedStatement pst=[Link]("select pass1 from info where


name=?");

[Link](1,uname);

ResultSet rs=[Link]();

if([Link]())

if([Link]([Link](1)))

[Link]("<h1> login Successfully!!!! </h1>");


}

else

[Link]("<h1> username does not exist..!!!! </h1>");

%> <jsp:include page="[Link]"></jsp:include>

<%

catch(Exception e)

[Link](e);

%>

</body>

</html>

Output

You might also like