Standards for creating well-formed JSP files

Although HTML code is embedded in Java™ Server Pages, strive to write JSP code that is easily readable. If you require some special XML manipulation that cannot be incorporated in the APIs, include a separate JSP file, so that HTML tags and Java code do not become mixed together.

Use the following standards when writing JSP files:
  • Tab spacing - Set the editor tab spacing to 4.
  • JavaScript files - Do not include any JavaScript in the JSP file. Put all JavaScript into a separate JS file.
  • HTML tags - Type all HTML tags and attributes in lowercase letters.
  • HTML attributes - Enclose all HTML element attribute values in double quotes. Single quotes and no quotes may work, but the standard is to use double quotes.
  • HTML tables - Minimize the number of tables in HTML pages. Especially, reduce the number of nested tables (a table within another table).
  • Tags - Close all tags, whether required or not.
  • Control elements - For each control element, add the get…Options attribute as the last attribute for that control element.
  • Comments - Enclose all comments in the following manner: <%/*……..*/%>
Tip: When finished coding a form, open it in any visual HTML editor to validate that the HTML is well-formed.