➡️ Retrieving data using Array List (array list of objects) ➡️ Code Optimization
Here, Array List us used to hold the list of object of type EmpBean.
JSP with Bean and Data access object (DAO). JSP is the normal jsp page which uses the bean to store employee information. The DAO file also know an Data Access Layer of our application, contains the code perform database operations such as add, change, delete etc.,
This video demonstrates the best usage of MVC (Model View & Controller) architecture in Java. ➡️ The model here is the EmpBean which holds the employee information. ➡️ The index page is the View which is interface used by client to enter the input and get to view the output. ➡️ The controller here the file which accepts the request from client and sets to bean and bean finally manages the database operation.
In this video the same example has been extended to support Edit/Update operation using display page. The link (url to edit page and ID of record to be updated) has been generated in the display page for to update record.
Once user click the Edit link , the control is transfer to edit.jsp page, where the the ID of the record to be updated is fetch from request object and the other details are set in text boxes so that user can edit the data.
There is a Update (submit) button which transfer user control to the update.jsp page, where all the submitted data is updated into emp table.
JSP with Bean and Data access object (DAO). JSP is the normal jsp page which uses the bean to store employee information. The DAO file also know an Data Access Layer of our application, contains the code perform database operations such as add, change, delete etc.,
This video demonstrates the best usage of MVC (Model View & Controller) architecture in Java. ➡️ The model here is the EmpBean which holds the employee information. ➡️ The index page is the View which is interface used by client to enter the input and get to view the output. ➡️ The controller here the file which accepts the request from client and sets to bean and bean finally manages the database operation.
In this video the same example has been extended to support Edit/Update operation using display page. The link (url to edit page and ID of record to be updated) has been generated in the display page for to update record.
Once user click the Edit link , the control is transfer to edit.jsp page, where the the ID of the record to be updated is fetch from request object and the other details are set in text boxes so that user can edit the data.
There is a Update (submit) button which transfer user control to the update.jsp page, where all the submitted data is updated into emp table.
JSP with Bean and Data access object (DAO). JSP is the normal jsp page which uses the bean to store employee information. The DAO file also know an Data Access Layer of our application, contains the code perform database operations such as add, change, delete etc.,
This video demonstrates the best usage of MVC architecture in Java. ➡️ The model here is the EmpBean which holds the employee information. ➡️ The index page is the View which is interface used by client to enter the input and get to view the output. ➡️ The controller here the file which accepts the request from client and sets to bean and bean finally manages the database operation.
CRUD – Create, Read, Update & Delete.
With reference to previous video 👉 https://youtu.be/63cIEAnz7Hc which consist of Add operation & Display operation.
In this video the same example has been extended to support Delete operation using display page. The link (url to delete page and ID of record to be deleted) has been generated in the display page for to delete record.
Once user click the Delete link , the control is transfer to delete.jsp page, where the the ID of the record to be deleted is fetch from request object and the same will be deleted from the emp table.
Overall process of example: When a new user select the “Sign Up” option from the registration page the request is sent to the SignUP Servlet, the servlet read the values of username and password from request. The new user registration module has been linked with Login module.
Servlet defines the Database connection with valid database connection information.
Prepared statement is used to check the username and password exists in users table. then, the same prepared statement is used to add new user information in database.
OS : Windows 10 Jdk : Version 8 IDE : Eclipse Mars Database : MySQL using MySql Workbench 5.2 CE Server : Apache Tomcat 7
Overall process of example: When a client/user select the “Submit” option from the clients page the request is sent to the Login Servlet, the servlet read the values of username and password from request.
Servlet defines the Database connection with valid database connection information.
Then, prepared statement is used to execute the queries. Here i have use used the prepared statement to check the username and password is exist in users table.
OS : Windows 10 Jdk : Version 8 IDE : Eclipse Mars Database : MySQL using MySql Workbench 5.2 CE Server : Apache Tomcat 7
This video features the CRUD operation using JDBC via servlet only, no JSP page is used to perform any database operation. CRUD is Create, Read, Update & Delete.
Index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Servlet with JDBC</title>
</head>
<body>
<form action="AddEmp" method="post">
<h1> Employee Management</h1>
<p> Enter Emp. No : <input type="text" name="txtEno"> </p>
<p> Enter Emp. Name : <input type="text" name="txtEname"> </p>
<p> Enter Emp. Salary : <input type="text" name="txtEsalary"> </p>
<p> DB Operation :
<select name="op">
<option value="1">Add</option>
<option value="2">Update</option>
<option value="3">Delete</option>
<option value="4">Display</option>
</select>
</p>
<p> <input type="submit" value="Submit"> </p>
</form>
</body>
</html>
It is generally the table operation to create, access, manipulate, and delete the data from a database table. Here, only a single Servlet is performing all the CRUD operation. Operation is decided by the client by selecting a proper option from list of choices.
When a client/user select the “Add” option, the internal value of that option is checked to perform the add operation, like wise when user/client select the “Update” operation the record is updated with given details.
If user/client decide to delete the record the valid number is given and the delete operation is carried.
Finally, if user decides to display all the record there is an option called “Display” to view all the details of the table.
OS : Windows 10 Jdk : Version 8 IDE : Eclipse Mars Database : MySQL using MySql Workbench 5.2 CE Server : Apache Tomcat 7