1.

How Do You Optimize Servlets?

Answer»

• 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.

• 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.



Discussion

No Comment Found