Favor Using JSP as the View Only
For a very simple application, using JSP for all parts of the application might be acceptable, but in most cases, I recommend following the Model-View-Controller (MVC) design pattern and using JSP only for the View. If you use JSP for all parts, you typically encounter these types of problems:
Common features need to be implemented in many places. If logic for access control, logging, and statistics collection is duplicated in most JSP pages, changes in these areas require changes to many parts of the application.
Business logic is harder to develop, debug, reuse, and maintain if it’s implemented as JSP action elements or Java code scriptlets in JSP pages. While some integrated development environments (IDEs) support a rich environment for JSP development and debugging, nonvisual aspects of the application are better done as regular Java classes, in which the full power of the language’s object-oriented features and standard program development tools can be leveraged.
Changes to the database schema or data source type require changes in all JSP pages that access the data source directly.
The application page flow is hard to visualize and manage because it’s spread throughout the application pages.
Combining JSP with other J2EE technologies solves all these problems. The frameworks described in Chapter 3, such as Apache Struts,[35] can help you develop easy-to-manage web applications. Struts provides a generic Controller server, dispatching requests ...
Get Java Enterprise Best Practices now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.