0% found this document useful (0 votes)
6 views3 pages

Java Experiments

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

Java Experiments

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

C:\XAMPP\TOMCAT\WEBAPPS\REGISTRATION

│ [Link]
│ [Link]
│ [Link]

└───WEB-INF
│ [Link]

├───classes
│ [Link]
│ [Link]
│ [Link]

└───lib
[Link]
[Link]

[Link]
<!DOCTYPE html>
<html>

<head>
<title>Login</title>
</head>

<body>
<h2>User Login</h2>
<form action="Register" method="post">
<label for="username">Username:</label><br>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password"
required><br><br>
<input type="submit" value="Login">
</form>
<% if ([Link]("errorMessage") !=null) { %>
<p style="color: red;">
<%= [Link]("errorMessage") %>
</p>
<% } %>
</body>

</html>

[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;

public class Register extends HttpServlet {


protected void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
[Link]("text/html;charset=ISO-8859-1");
PrintWriter out = [Link]();
String n = [Link]("username");
String s = [Link]("password");
try {
[Link]("[Link]");
Connection con =
[Link]("jdbc:mysql://localhost:3306/test", "root",
"");
PreparedStatement ps = [Link]("insert into
student values(?,?)");
[Link](1, n);
[Link](2, s);
int i = [Link]();
if (i > 0)
[Link]("You are Successfully registered...." + n);
[Link]("Your uid is:" + s);
} catch (Exception e2) {
[Link](e2);
[Link](e2);
}
[Link]();
}
}

[Link]
<!DOCTYPE html>
<html>

<head>
<title>Welcome</title>
</head>

<body>
<h2>Welcome! You have successfully logged in.</h2>
<!-- Further operations can be linked here -->
</body>

</html>

You might also like