Two Laptop Bag
The moose likes Servlets and the fly likes Storing variables in the session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Storing variables in the session" Watch "Storing variables in the session" New topic

Storing variables in the session

rastas biggs
Ranch Hand

Joined: Sep 24, 2004
Posts: 41
Hi there,

Rather than appeanding variables to a url is it better on my controller servlet to store the variables in the session?

Can some one give me an idea of the advantage/disadvantages to this approach?

Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

Storing items in Session Variables provides many advantages. There's a free online version of the first edition of Core Servlets & JavaServer Pages avaialbe at the website (the link to the pdf is down towards the bottom of the home page). There is a chapter on Session Management which disusses the advantages of session variables over parameters. Keep in mind that that edition of the book is based on the older Servlet & JSP specs (specifically the Servlet v2.1 & 2.2 and JSP 1.1 specs). A lot was added in both the 2.3/1.2 and 2.4/2.0 versions of the specifications. Nonetheless, the basic concepts of session management remain the same, but the tools (i.e. the available classes and methods) have changed.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Here is one more read chapter 9 of this book.
I agree. Here's the link:
subject: Storing variables in the session
jQuery in Action, 3rd edition