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.
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.
Model View & Controller βΆοΈ It is a design pattern that separates the business logic, presentation logic and data. βΆοΈ Model represents the state of the application i.e. data. It can also have business logic. (Data & business logic) βΆοΈ View represents the presentation i.e. UI (User Interface). βΆοΈ Controller acts as an interface between View and Model. Controller intercepts all the incoming requests. (Controller is a request handler)
OS : Windows 10 Jdk : Version 8 IDE : Eclipse Mars Server : Apache Tomcat 7
Model View & Controller βΆοΈ It is aΒ design patternΒ that separates the business logic, presentation logic and data. βΆοΈ ModelΒ represents the state of the application i.e. data. It can also have business logic. (Data & business logic) βΆοΈ ViewΒ represents the presentation i.e. UI (User Interface). βΆοΈ ControllerΒ acts as an interface between View and Model. Controller intercepts all the incoming requests. (Controller is a request handler)
OS : Windows 10 Jdk : Version 8 IDE : Eclipse Mars Server : Apache Tomcat 7
JSP Application object: βΆοΈ It represents the context within which the JSP is executing. βΆοΈ It has application scope. βΆοΈThe application object represents the application to which the JSP is executing to which the JSP page belongs. βΆοΈ It is an instance of the javax.servelt.ServletContext.
JSP Config object: βΆοΈ config is an implicit object of type ServletConfig. βΆοΈ This object can be used to get initialization parameter for a particular JSP page. βΆοΈ The config object is created by the web container for each jsp page.
OS : Windows 10 Jdk : Version 8 IDE : Eclipse Mars Server : Apache Tomcat 7
JSP Application object: βΆοΈ It represents the context within which the JSP is executing. βΆοΈ It has application scope. βΆοΈThe application object represents the application to which the JSP is executing to which the JSP page belongs. βΆοΈ It is an instance of the javax.servelt.ServletContext.
JSP Config object: βΆοΈ config is an implicit object of type ServletConfig. βΆοΈ This object can be used to get initialization parameter for a particular JSP page. βΆοΈ The config object is created by the web container for each jsp page.
OS : Windows 10 Jdk : Version 8 IDE : Eclipse Mars Server : Apache Tomcat 7
jsp:use bean tag is used to declare and used object using tag format in jsp page.
Bean object is declared using use:bean tag in jsp page. set:property tag is used to set the values and get:property tag used to get the values from bean object.
Scope for jsp:bean is set to request so that when a request is transfer to another page its also accessible there.
following is the list of important attributes of jsp:usebean tag β‘ id (name of the object) β‘ name (name of the fully qualified class name of bean) β‘ scope (application,request,session and page), default is page.
In this example bean values are set in process.jsp and then its transferred to welcome.jsp using request dispatcher. Welcome.jsp access the values get the values which were set in process.jsp page.
Summary of files used in this example β‘οΈ index.jsp (to accept client input) β‘οΈ process.jsp (to declare and set the values in bean) β‘οΈ UserBean.java (user bean POJO file) β‘οΈ welcome.jsp (welcome page to display)
βοΈ jsp:useBean standard action tag is use to establish a connection between a jsp page and a java bean. βοΈ In web applications of java, jsp and java bean communication is required in the following two cases: 1οΈβ£In a real-time MVC project, a model class (business class) will set the data to a java bean and a jsp (view) will read the data from a bean and finally displays it on the browser. 2οΈβ£If multiple jsp pages need common java logic then it separates that java code into a bean and then we call the bean from jsp.
Video features the following: π How to define Bean class in java π How to use bean class in JSP scriplet π How to use bean using jsp:useBean
It contains the following files π Index.jsp π process.jsp π UserBean.java