Thursday, September 07, 2006

Java Servlets Best Practices

  1. Use init() method to cache static data
  2. Use StringBuffer rather than using + operator when you concatenate multiple strings
  3. Use print() method rather than println() method
  4. Use ServletOutputStream rather than PrintWriter to send binary data
  5. Initialize the PrintWriter with proper size
  6. Flush the data partly
  7. Minimize code in the synchronized block
  8. Set the content length
  9. Release resources in destroy() method.
  10. Implement getLastModified() method to use browser cache and server cache
  11. Use application server caching facility
  12. Use Mixed session mechanisms such as HttpSession with hidden fields
  13. Remove HttpSession objects explicitly in your program whenever you finish the task
  14. Reduce session time out value as much as possible
  15. Use 'transient' variables to reduce serialization overhead if your HttpSession tracking mechanism uses serialization process.
  16. Disable servlet auto reloading feature.
  17. Use thread pool for your servlet engine and define the size as per application requirement.

Get more information

Tags: java servlets, stringbuffer, thread pool, best practices

Can't find what you're looking for? Try Google Search!
Google
 
Web eshwar123.blogspot.com

Comments on "Java Servlets Best Practices"