Wednesday, September 20, 2006

Tell me about JSP best practices?

Separate HTML code from the Java code: Combining HTML and Java code in the same source code can make the code less readable. Mixing HTML and scriplet will make the code extremely difficult to read and maintain. The display or behaviour logic can be implemented as a custom tags by the Java developers and Web designers can use these Tags as the ordinary XHTML tags.

Place data access logic in JavaBeans: The code within the JavaBean is readily accessible to other JSPs and Servlets.

Factor shared behaviour out of Custom Tags into common JavaBeans classes: The custom tags are not used outside JSPs. To avoid duplication of behaviour or business logic, move the logic into JavaBeans and get the custom tags to utilize the beans.

Choose the right “include” mechanism: What are the differences between static and a dynamic include? Using includes will improve code reuse and maintenance through modular design.

Use style sheets (e.g. css), template mechanism (e.g. struts tiles etc) and appropriate comments (both hidden and output comments).

0 Comments:

Post a Comment

<< Home