This document contains tips for writing faster servlets.
Useful Performance Links
Practices to improve performance in Servlets from
- Use init() 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 rather than PrintWriter to send binary data
- Initialize the PrintWriter with proper size
- Flush the data partly
- Minimize code in the synchronized block
- Set the content length
- Release resources in destroy() method.
- Implement getLastModified() method to use browser cache and server cache
- Use application server caching facility
- Use Mixed session mechanisms such as HttpSession with hidden fields
- Remove HttpSession 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 HttpSession tracking mechanism uses serialization process.
- Disable servlet auto reloading feature.
- Use thread pool for your servlet engine and define the size as per application requirement.
and JSP performance tips from Java
Programming Tips from CoolServlets.com