Translate

Friday, November 23, 2012

TUNINING SERVLETS AND JSP



TUNINING SERVLETS AND JSP


•Don‘t use SingleThreadModel (which is depricated as of Servlet 2.3 API)

•Make the servlet thread safe

•By making smaller synchronized blocks or
•By replacing the member variables of a servlet with local (to service) variables

•Use StringBuffer or StringBuilder or other efficient String or byte array-building mechanism
•Avoid generating intermediate String and other objects whenever possible
•Avoid the += with Strings

•Use the browser‘s caching mechanism to have pages re-read by correctly implementing the getLastModified() method
•Use the <%@ include ..%> directive than the action
•Minimize the scope of to ―page where possible
•response.sendRedirect(..) is slower than

•Avoid the creation of HttpSession objects if not needed

•<%@ page session=”false” %>
•Specify the session timeout in web.xml
•Keep the data common to all the users in the application scope than the session
•Avoid having the session objects serialized by the container
•Remove the session object explicitly with the session.invalidate() method, when the session objects are no longer needed (for example, the user logs out, or a wizard finished)

•Implement the HttpSessionBindingListener for any resources that need to be cleaned up when sessions terminate
•Make the best use of init(), destroy(), jspInit() and jspDestroy()

•As they are ideal for creating and destroying limited and expensive resources such as cached objects and database connections

•Compress the output if the browser supports displaying compressed pages

•Filters provide excellent features of addressing cross cutting concerns, but they have overhead associated with their mechanism
•Increase the server TCP/IP listen queues
•Disable auto-reloading features that periodically reload servlets and JSPs
•Tune the pool sizes in the server

No comments: