Introduction
Do not create HttpSessions in JSPs by default. JSPs create HttpSessions by default. If you do not need an HttpSession, you can enhance performance by simply not taking the default with a one line JSP directive. Lab measurements have yielded a 5% performance throughput when this default is not used.
This best practice applies to the following product, version, and platform:
- WebSphere Application Server Base, all platforms, versions 3.0.2.x, 3.5.x, 4.0
Back to top
Recommendation
Performance best practices find performance benefits by simply avoiding defaults. By default, JSP files create HttpSessions. This is in compliance with J2EE to facilitate the use of JSP implicit objects, which can be referenced in JSP source and tags without explicit declaration. HttpSession is one of those objects. If you do not use HttpSession in your JSP files, then you can save some performance overhead with the following JSP page directive:
<%@ page session="false"%>
Figure 1. Avoiding JSP File HttpSession By Default
Back to top
Alternative
There is no alternative to this best practice. Do not take this default if you do not require a HttpSession.
Resources
About the author
Harvey Gunther is a Senior Performance Analyst with the IBM WebSphere Product Development team in Raleigh, North Carolina.
Comments (Undergoing maintenance)
Back to top
Trademarks | My developerWorks terms and conditions
Help: Update or add to My dW interests
What's this?
This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.
And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.
View your My developerWorks profile
Return from help
static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=13207
ArticleTitle=Best Practice: Not creating HttpSessions in JSPs by default
publish-date=08082001
author1-email=hgunther@us.ibm.com
author1-email-cc=