How to improve Servlet Performance

  • Cache static data using jspInit() method.
  • Release static data in jspDestroy() method.
  • To concatenate string use, StringBuffer.
  • Do not use println() method.
  • Do not use PrintWriter to send binary data. Use ServletOutputStream.
  • Always flush data in sections.
  • Use getLastModified() method to handle browser and server cache.
  • Use application server cache.
  • Use session in following order: HttpSession, Hidden fields, Cookies, URL rewriting.
  • Always remove HttpSession explicitly.
  • Disable Servlet auto reloading.