Today, Budi walks us through a refresher and brief overview of server JSP programming. Today's portion covers JavaServer Pages (JSP), with a thorough overview of JavaBeans and Tags. This excerpt comes from chapter one of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983-7, 2004).
Java Web application can be designed based on Model 1 or Model 2. Model 1 is for very small applications that will never grow more complex and consists of JSP pages only. Each JSP page references another JSP page, making maintenance very hard as the application grows bigger. The Model 2 architecture is the recommended design model for medium sized and large applications, and is based on the Model-View-Controller (MVC) pattern. A Model 2 architecture is indicated by the presence of a controller servlet between the client browser and the JSP pages (or the servlets that present the content). See Figure 6. The controller servlet dispatches HTTP requests to the corresponding presentation JSP pages—based on the request URL, input parameters, and application state. In this model, presentation parts (JSP pages or servlets) are isolated from each other.
Figure 6Model 2 Architecture
Model 2 applications are more flexible and easier to maintain, and to extend, because views do not reference each other directly. The Model 2 controller servlet provides a single point of control for security and logging, and often encapsulates incoming data into a form usable by the back-end MVC model.
JSF is based on the Model 2 architecture, in which there is one controller servlet and multiple JSP pages. The controller servlet is called Faces Servlet and is already provided by the JSF implementation. The development of a JSF application focuses on the authoring of JSP pages and the writing of other components.
To start developing JSF applications, you need to be familiar with servlets and JSP technologies and related technologies, especially JavaBeans and custom tag libraries. It is also helpful if you are familiar with the Model 2 architecture as JSF is based on this design model. This chapter provided a brief review of the four technologies as well as the Model 2 architecture. For more details on these technologies you should consult a servlet/JSP book, such as my own “JavaWeb Development with Servlets, JSP, and EJB, Second Edition” (Sams Publishing, 2004).
Remember: This is part two of the first chapter of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983). Stay tuned for more chapters of developer books from McGraw-Hill/Osborne. Buy this book!