[ Team LiB ] Previous Section Next Section

JSP Best Practices

To optimize scalability, maintainability, and deployability, implement a n-tier architecture (Model-View-Controller), separating presentation, application logic, and data archiving.

When implementing complex logic within your presentation layer, use JavaBeans rather than coding intensive scripting blocks. This model promotes code readability and maintainability by organizing application business logic into Java modules. In general, separate Java from your HTML.

Use appropriate include options. You should use the include directive unless you can justify using the include action. If business logic and other Java code are properly abstracted, use of the include directive should promote Java code reduction within your JSP page.

To further reduce redundant constructs and improve code readability/maintainability, the use of templates and cascading style sheets should be optimized.

For clarity, use the shorthand JSP tags rather than the more cumbersome XML equivalent tags where possible. However, if you're using XML validation tools, you must use XML equivalent tags.

JSP pages are best implemented within the greater context of an n-tiered layered architecture as provided with the Model-View-Controller design pattern. As discussed in more detail within Chapter 16, JSPs provide the client view or portal into the application. Actual processing of application logic would occur within the Controller or middle-tier layer. The data manipulated as a result of client requests would reside within the Model layer.

    [ Team LiB ] Previous Section Next Section