Skip to main content

Best Practice: Not creating HttpSessions in JSPs by default

Harvey Gunther (hgunther@us.ibm.com), Senior Performance Analyst, IBM
Harvey Gunther is a Senior Performance Analyst with the IBM WebSphere Product Development team in Raleigh, North Carolina.

Summary:  This best practice recommends that you do not create HttpSessions in JSPs by default to improve performance.

Date:  08 Aug 2001
Level:  Intermediate
Activity:  393 views

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

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
Avoiding JSP File HttpSession By Default

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)



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

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

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=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers