[ Team LiB ] Previous Section Next Section

When to Use JSPs

When should you use JSP pages? JSP pages should be used when interactive Web-based content is desired over static content; that is, when content is predicated on user response rather than pre-scripted static text. This dynamic Web-based model is usually accomplished by implementing an n-tier architecture, such as Model-View-Controller, where presentation, application/business logic, and data archiving are layered. Within this layered approach, JSPs should be implemented as the presentation. The JSPs should implement minimal Java code, while providing only a client portal into the application. User requests are serviced by the Controller layer using servlets or other Java objects (such as JavaBeans, Session EJBs, tag libraries, and generic user-defined objects) to implement business and application logic. See Chapter 16 for further details on the MVC design pattern.

Once an n-tier architecture is implemented, JSP pages are useful in situations where presentation development is stable and developed independently or remotely from application logic. In this situation, application development can continue, with updated presentation being shipped to process developers as appropriate. This model is especially effective in situations where presentation is developed in multiple markup formats (other than HTML), such as DHMLT, WML, and XML.

For non-tiered solutions where Web-based applications must run on a variety of platforms, JSP pages should be used to exploit the inherent portability of the Java programming language.

    [ Team LiB ] Previous Section Next Section