JSP Sessions

Posted on 2002-04-17
Last Modified: 2010-03-31

I have been using scripting languages for a while now (ASP,PHP) and have only started learning JSP recently.

I was wondering what all the fuss was about using sessions, as it seems more prominent in all the JSP docs and tutorials.

What can be achieved using sessions that can't be my not using them? ie. what is the advantages and/or disadvantages?

I have seen some of the code, but have no idea how sessions work, and whether I should implement it in an upcoming project?

Also, some tuturial or doc for a beginner might help.

Next Project includes:

- User Login/verifying.
- Oracle 8i database connectivity.


Question by:barnarp
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

Jan Louwerens earned 50 total points
ID: 6949314
A session is an object that stays with a client the whole time they're on your site. You can store information in the session that is associated with a client.
For example, once a client logs in to your website, you can store the client's login name (or any info uniquely identifying the client: ID, email address, etc) inside the session and will stay with that client until you invalidate it from with your code, or the user closes the browser.

Expert Comment

ID: 6949821
jlouwere is right.

Aside from a session being able to stick with the client (that's why it is called session because it is the client's session with your server, he he he), its other advantages are:

1) storing data in a client's session cannot be seen by anyone compared to storing data in your html forms or in FAT URLs which can be seen when your view source from the browser or blatantly shown in your browsers Address bar.

2) you can store an unlimited amount of data in the client's session object (limited of course by the server's hardware) unlike using FAT URLs which usually can contain less than 500 chars.

Definitely you'd want to use sessions for checking login data of your clients.  Any sensitive or large-size data you want stored or connected to your client's "session" with your server should be stored in sessions.

Expert Comment

by:Jan Louwerens
ID: 6951266
If you have a large amount if clients, thought, storing large amounts of data n the sesion could result in storage (memory) problems, which in turn could affect site performance. For really large abounts of data, you'd want to store it in a database, or something similiar, and retrieve it upon demand.
And GET URLs are limited to 256 chars (as iodear states), so you can't store much there.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 6951580

Atleast I now have a starting point!



Author Comment

ID: 6951581

Atleast I now have a starting point!



Expert Comment

by:Jan Louwerens
ID: 6951692
barnarp, I noticed there was a problem with the answer (there is still a Proposed Answer, and no real Accepted Answer, although it shows there should be one).
Could you describe to me exactly what happened, from your user perspective, that might have caused that to happen?
Did anything go wrong while accepting the answer? Where you logged out by the system? Any information you provide could help to prevent this from occuring in the future.
Thank you.

Author Comment

ID: 6958920

didn't really notice. I did however think I accept the comment as an answer, but later found out that I just posted a normal comment. I then accepted the answer a second time.

LVL 35

Expert Comment

ID: 8682523
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- points to jlouwere

Please leave any comments here within the
next seven days.


Cleanup Volunteer

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 262
Why doesn't this text field show up on my Applet frame? 2 40
Notify sent to other threads in Java 9 53
hashmap order 17 59
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question