JSP is java based technology which is used to simplify the development of the dynamic webpage. JSP is used to separate the dynamic content of the web page from its content with the help of HTML and JSP tags.
There are two JSP Model Architecture:
- JSP Model 1 Architecture:
JSP Model1 Architecture or JSP Centric architecture contains JavaBeans or EJB Model Object, View JSP pages and Action JSP Pages.
In model 1 architecture, the incoming request is directly sent to the JSP page from a web browser and JSP page is responsible for processing it and sending back to the client. All the data access is performed using beans so there is still a separation of presentation from content.
Advantages of JSP Centric Model:
- Small number of components are required to build the applications.
- A small number of technologies, reducing the learning curve for inexperienced resources.
Disadvantage of JSP Centric Model:
- Architecture produces a tightly coupled application with hard-coded page names.
- Access JSP pages are primarily java codes, but cannot be developed, compiled and debugged as easily as a java code.
- Re-use of processing and validation is hampered by its placement in form-specific action JSP pages.
- JSP Model 2 Architecture:
JSP Model 2 Architecture or Servlet-Centric Architecture contains Java beans or EJB Model Objects, view JSP pages and servlet or command classes.
It is basically a Model View Controller approach involved notification/event models, direct manipulation of model objects. MVC basically interposes controller component between View and Model Components where the controller is responsible for navigation, presentation-tier logic, validation and emphasizes the separation of presentation logic and model objects.
Features of MVC:
- Clients do not request pages directly. All clients requests go to controller servlet.
- Each request includes data i.e; the request action, any parameter for that action.
- Controller servlet decides which page should be returned to the user, augment requests object with data to be displayed to the user.
Advantages of MVC:
- MVC approach simplifies JSP pages by providing no navigation code inside them and no complete data manipulation.
- Clean separation of presenting and processing logic.
- The front components present a single point of entry into the application, thus making the management of application state, security, and presentation uniform and easier to maintain.
- Multiple views using the same model.
The processing is divided between presentation (JSPs) and controllers(front components). Presentation components are JSP pages that generate HTML/XML response that determines the user interface rendered by the browser. Front components do not handle any presentation issues, but rather process, all the HTTP request. They are responsible for creating beans or object used by presentation components, as well as for deciding, depending on the user’s action which presentation component to forward the request to. The front component can either be implemented as servlet or JSP.
- Request processing
- Creation of any beans or objects used by the presentation JSP.
- Deciding, depending on the user’s action, which JSP to forward the request to.
- Data validation
- Introduction to Model View View Model (MVVM)
- How to get access to the containing form of an input?
- HTTP headers | Access-Control-Max-Age
- CSS | Box model
- HTTP headers | Access-Control-Allow-Credentials
- HTTP headers | Access-Control-Allow-Origin
- How to access an associative array by integer index in PHP?
- Basics of SOAP - Simple Object Access Protocol
- Client-Server Model
- Page Object Model (POM)
- AngularJS | ng-model Directive
- Sandbox Security Model
- Laravel | Eloquent Model Basics
- AngularJS | ng-model-options Directive
There is no processing logic within the presentation JSP itself: it is simply responsible for retrieving the objects that may be previously created by the servlet and extracting the dynamic content for insertion with static templates.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.