0% found this document useful (0 votes)
27 views

Lab02.2 JDBC WebApp

Uploaded by

tungnkss160730
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Lab02.2 JDBC WebApp

Uploaded by

tungnkss160730
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Building an Java Web Application

Using HTML, Servlet & JDBC


Requirements
Create a java web application (using HTML, Servlets and JDBC) to perform functions
as login and manage users (CRUD) for admin role

Lab Objectives
In this lab, you will be:
▪ Create Java web project using the NetBean IDE
▪ Create the web pages by HTML
▪ Apply passing data from HTML to Servlet by GET and POST method

1|Page
▪ Performs CRUD functions by SqlJDBC driver and SQL Server
▪ Run the project and test the functions of the application

Step 01. Create a Java Web application named IntroductionJDBC is


structured as follows:

Create folder named lib in WEB-INF


and copy sqljdbc driver( file .jar) that
match with SQL Server version on the
machine to lib folder

Right-click on the project, select


Properties | Libraries | Add
JAR/Folder then select sqljdbc driver
in the lib folder that matches the Sql
Server version on the machine.

-Open SQL Server Management Studio and create a database named


SampleDB has a table named Registration as follows:

2|Page
Step 02. Write codes for the classes in the DBUtils package as the follows:
• User.java

• UserDAO.java

3|Page
4|Page
5|Page
6|Page
Step 03. Write codes for the classes in the UserServlet package as the
follows:
• LoginServlet.java

7|Page
• ProcessUserServlet.java

8|Page
• ManageUserServlet.java

9|Page
Step 04. Write HTML codes for the web pages as the follows:
• Login.html page

• AddUser.html page

• DeleteUser.html page

10 | P a g e
• UpdateUser.html page

Step 05. Open the web.xml in the WEB-INF folder then update as the follows:

Step 06. Right-click on IntroductionJDBC project, select Run to run the web
app then test all functions.

11 | P a g e

You might also like