Lab 08 Servlet - JDBC - Web Eng
Lab 08 Servlet - JDBC - Web Eng
Task [100]
Create a Servlet application that allows a user to perform CRUD (Create, Read, Update and Delete) operations on an address-book.
The application should use the GET method for reading, and the POST method for creating, updating and deleting the person record.
Step 1: Create a new Java web project and add a Servlet class (e.g., personInfo).
Step 2: In doGet() method, add code to get and display all the available records in HTML tabular format. The table should be
generated dynamically by reading the records from the database and adding them as rows to the HTML table.
Step 3: In doPost() method, add code to handle the creation, updation and deletion of person’s record in the database. The
servlet class should handle the following actions:
Creation: A user should be able to add a new person’s record to the database by submitting a form that includes fields for
the person's name, address and phone.
Updating: A user should be able to update the details of an existing record by submitting a form that includes fields for the
person's name, address and phone.
Deletion: A user should be able to delete a person’s record from the database by submitting a form with a field for the
person’s name.
Step 4: Create web.xml file and map the servlet class to a specific URL pattern, for example, "/personInfo"
Step 5: Create HTML forms for adding, updating and deleting person records. The forms should use the POST method and have the
action set to the URL pattern mapped to the servlet in web.xml
Step 6: Test the application by adding, updating and deleting persons’ records, and ensure that the changes are reflected in the
table.
Instructions:
You need to create appropriate database, and table to save the persons’ records.
A person record shall consists of name, address, and phone.
In doPost() method, you can have if-else if conditions to perform the specific task (i.e., creation, updating and
deletion).
Deploy the JDBC connector file in the lib folder which shall be placed parallel to the classes folder in your web-
application.
BEST OF LUCK