JSPs Best Practices
- Use jspInit() method to cache static data
- Use StringBuffer rather than using + operator when you concatenate multiple strings
- Use print() method rather than println() method
- Use ServletOutputStream instead of JSPWriter to send binary data
- Initialize the 'out' object (implicit object) with proper size in the page directive.
- Flush the data partly
- Minimize code in the synchronized block
- Set the content length
- Release resources in jspDestroy() method.
- Give 'false' value to the session in the page directive to avoid session object creation.
- Use include directive instead of include action when you want to include the child page content in the translation phase.
- Avoid giving unnecessary scope in the 'useBean' action.
- Do not use custom tags if you do not have reusability.
- Use application server caching facility
- Use Mixed session mechanisms such as 'session' with hidden fields
- Use 'session' and 'application' as cache.
- Use caching tags provided by different organizations like openSymphony.com
- Remove 'session' objects explicitly in your program whenever you finish the task
- Reduce session time out value as much as possible
- Use 'transient' variables to reduce serialization overhead if your session tracking mechanism uses serialization process.
- Disable JSP auto reloading feature.
- Use thread pool for your JSP engine and define the size of thread pool as per application requirement.
Tags: jsps, best practices, session
Can't find what you're looking for? Try Google Search!
Comments on "JSPs Best Practices"