You are here : Home » knowledge exchange


Best Practices to improve performance in Servlets

Best Practices to improve performance in Servlets
  • Use init() method to cache static data
  • Use StringBuffer / StringBuilder 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.

Knowledge Exchange about Php Java, Asp.Net, SEO At Narola Infotech



Copyright © 2005-2011 Narola Infotech, Custom Software & Website Development Company | All Rights Reserved.

Find Us on