Web Development with JAVA | Practical Solutions
Web Development with JAVA
Practical Solutions
Practical #16 to #30
HTML | CSS | Java Servlet | MySQL |
Tomcat | jQuery
Academic Year 2025-2026
Page 1 of 12
Web Development with JAVA | Practical Solutions
16. Installation of Apache Tomcat Server
Steps:
1. Download Apache Tomcat from the official website.
2. Install Java JDK first.
3. Extract Tomcat zip file.
4. Open the bin folder.
5. Run [Link].
6. Open browser and type:
[Link]
Result: Apache Tomcat server starts successfully.
17. Installation of IDE (NetBeans)
Steps:
7. Download NetBeans IDE.
8. Install Java JDK.
9. Run NetBeans installer.
10. Select installation path.
11. Complete installation.
12. Open NetBeans IDE.
Result: NetBeans IDE installed successfully.
18. Deploy Simple Website in Apache Tomcat Server
[Link]
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
</head>
<body>
<h1>Welcome to Apache Tomcat</h1>
</body>
</html>
Page 2 of 12
Web Development with JAVA | Practical Solutions
Steps:
13. Create folder inside webapps.
14. Save [Link] in folder.
15. Start Tomcat server.
16. Open browser:
[Link]
Result: Website deployed successfully.
19. Design a Page Layout using HTML and CSS
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: Arial; }
header { background: #333; color: white; padding: 20px; text-align: center; }
nav { background: #555; padding: 10px; }
nav a { color: white; margin: 10px; text-decoration: none; }
section { padding: 20px; }
footer { background: #333; color: white; text-align: center; padding: 10px; }
</style>
</head>
<body>
<header><h1>My Website</h1></header>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Contact</a>
</nav>
<section>
<h2>Welcome</h2>
<p>This is page layout design.</p>
</section>
<footer>Copyright 2026</footer>
</body>
</html>
Result: A simple webpage layout is created.
Page 3 of 12
Web Development with JAVA | Practical Solutions
20. Install ODBC Driver
Steps:
17. Open Control Panel.
18. Open Administrative Tools.
19. Select ODBC Data Sources.
20. Add MySQL ODBC Driver.
21. Configure database connection.
Result: ODBC driver installed successfully.
21. Install and Configure MySQL
Steps:
22. Download MySQL Installer.
23. Install MySQL Server.
24. Set username and password.
25. Open MySQL Command Line.
26. Create database.
SQL Query:
CREATE DATABASE studentdb;
Result: MySQL configured successfully.
22. Design User Registration Form and Store User in Database
[Link]
<!DOCTYPE html>
<html>
<body>
<form action="RegisterServlet" method="post">
Name: <input type="text" name="name"><br><br>
Email: <input type="email" name="email"><br><br>
Password: <input type="password" name="password"><br><br>
<input type="submit" value="Register">
</form>
</body>
</html>
Page 4 of 12
Web Development with JAVA | Practical Solutions
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
public class RegisterServlet extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String name = [Link]("name");
String email = [Link]("email");
String password = [Link]("password");
try {
[Link]("[Link]");
Connection con = [Link](
"jdbc:mysql://localhost:3306/studentdb","root","root");
PreparedStatement ps = [Link](
"insert into users values(?,?,?)");
[Link](1, name);
[Link](2, email);
[Link](3, password);
[Link]();
[Link]().println("Registration Successful");
} catch(Exception e) {
[Link](e);
}
}
}
SQL Table:
CREATE TABLE users(
name VARCHAR(50),
email VARCHAR(50),
password VARCHAR(50)
);
Result: User registration data stored in database.
Page 5 of 12
Web Development with JAVA | Practical Solutions
23. Design Login User Form and Validate User
[Link]
<form action="LoginServlet" method="post">
Email: <input type="email" name="email"><br><br>
Password: <input type="password" name="password"><br><br>
<input type="submit" value="Login">
</form>
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
public class LoginServlet extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String email = [Link]("email");
String password = [Link]("password");
try {
[Link]("[Link]");
Connection con = [Link](
"jdbc:mysql://localhost:3306/studentdb","root","root");
PreparedStatement ps = [Link](
"select * from users where email=? and password=?");
[Link](1, email);
[Link](2, password);
ResultSet rs = [Link]();
if ([Link]()) {
[Link]().println("Login Successful");
} else {
[Link]().println("Invalid User");
}
} catch(Exception e) {
[Link](e);
}
}
}
Result: User login validated successfully.
24. Show All Registered Users in a Grid
[Link]
import [Link].*;
Page 6 of 12
Web Development with JAVA | Practical Solutions
import [Link].*;
import [Link].*;
import [Link].*;
public class ShowUsersServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
[Link]("text/html");
try {
[Link]("[Link]");
Connection con = [Link](
"jdbc:mysql://localhost:3306/studentdb","root","root");
Statement st = [Link]();
ResultSet rs = [Link]("select * from users");
PrintWriter out = [Link]();
[Link]("<table border='1'>");
[Link]("<tr><th>Name</th><th>Email</th></tr>");
while ([Link]()) {
[Link]("<tr><td>" + [Link](1) + "</td><td>"
+ [Link](2) + "</td></tr>");
}
[Link]("</table>");
} catch(Exception e) {
[Link](e);
}
}
}
Result: All users displayed in grid format.
Page 7 of 12
Web Development with JAVA | Practical Solutions
25. Search Users by Name and Show in Grid
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
public class SearchServlet extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String name = [Link]("name");
try {
[Link]("[Link]");
Connection con = [Link](
"jdbc:mysql://localhost:3306/studentdb","root","root");
PreparedStatement ps = [Link](
"select * from users where name=?");
[Link](1, name);
ResultSet rs = [Link]();
PrintWriter out = [Link]();
[Link]("<table border='1'>");
while ([Link]()) {
[Link]("<tr><td>" + [Link](1) + "</td><td>"
+ [Link](2) + "</td></tr>");
}
[Link]("</table>");
} catch(Exception e) {
[Link](e);
}
}
}
Result: User searched successfully.
26. Update User Profile
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
public class UpdateServlet extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String email = [Link]("email");
Page 8 of 12
Web Development with JAVA | Practical Solutions
String name = [Link]("name");
try {
[Link]("[Link]");
Connection con = [Link](
"jdbc:mysql://localhost:3306/studentdb","root","root");
PreparedStatement ps = [Link](
"update users set name=? where email=?");
[Link](1, name);
[Link](2, email);
[Link]();
[Link]().println("Profile Updated");
} catch(Exception e) {
[Link](e);
}
}
}
Result: User profile updated successfully.
Page 9 of 12
Web Development with JAVA | Practical Solutions
27. Form Validation using jQuery
<!DOCTYPE html>
<html>
<head>
<script src="[Link]
<script>
$(document).ready(function() {
$("form").submit(function() {
var name = $("#name").val();
if (name == "") {
alert("Name is required");
return false;
}
});
});
</script>
</head>
<body>
<form>
<input type="text" id="name">
<input type="submit">
</form>
</body>
</html>
Result: Form validated using jQuery.
28. Create a Form using Java Servlet
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
public class FormServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
PrintWriter out = [Link]();
[Link]("<html><body>");
[Link]("<form>");
[Link]("Name: <input type='text'><br><br>");
[Link]("<input type='submit'>");
[Link]("</form>");
[Link]("</body></html>");
}
}
Page 10 of 12
Web Development with JAVA | Practical Solutions
Result: Form created successfully using servlet.
29. Store and Retrieve Data from Session
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
public class SessionServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
HttpSession session = [Link]();
[Link]("username", "Admin");
String user = (String) [Link]("username");
[Link]().println("Session User: " + user);
}
}
Result: Session data stored and retrieved successfully.
Page 11 of 12
Web Development with JAVA | Practical Solutions
30. Create Address Book Application
[Link]
<!DOCTYPE html>
<html>
<body>
<h2>Address Book</h2>
<form>
Name: <input type="text"><br><br>
Phone: <input type="text"><br><br>
Address: <input type="text"><br><br>
<input type="submit" value="Save">
</form>
</body>
</html>
SQL Table:
CREATE TABLE addressbook(
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
phone VARCHAR(20),
address VARCHAR(100)
);
Result: Address Book application created successfully.
Conclusion
All Web Development with JAVA practicals (16-30) completed successfully using:
• HTML
• CSS
• Java Servlet
• MySQL
• Apache Tomcat
• NetBeans IDE
• jQuery
Page 12 of 12