Introduction
There are many Java frameworks to create web applications one such framework is Struts. Before creating web applications, we should be familiar with design models or design patterns. There are two approaches for building web applications, Model 1 Architecture and Model 2 (MVC) Architecture. So, let us learn about these two approaches one by one.
Model 1 Architecture
Model 1 Architecture is one of the two approaches for building web applications.
Early web application design considered the JSP page as the centrepiece of the entire application. The JSP page, also known as Model 1 architecture, is in charge of extracting HTTP request parameters, calling the business logic, and managing the HTTP session, in addition to containing the display elements to output HTML.
Although Model 1 Architecture is best suited for simple applications, it usually leads to a considerable amount of scriptlets, especially if there is a substantial amount of request processing to be performed.
Model 1 Architecture Illustration -
- The browser sends an HTTP request to JSP
- JSP communicates with JavaBeans and calls the business logic
- JavaBeans connects to the database and gets/saves data
- The response generated by the JSP is sent to the browser
Advantages of Model 1 Architecture
- Quick and easy to develop simple web applications.
- Provides better separation of concern - presentation and business logic can be easily separated.
Disadvantages of Model 1 Architecture
- Navigation control is decentralised - Since the logic to decide the next page is contained on every page, that means if the name of a JSP page is changed that is referred to by other pages, we need to update it in all the pages that lead to the maintenance issue.
- Time-consuming - We need to invest extra time to develop custom tags in JSP in order to avoid using the scriptlet tag.
- Hard to extend - It is suitable for simple applications but not for large ones.