Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes session objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session objects" Watch "session objects" New topic
Author

session objects

sudha siva
Ranch Hand

Joined: Sep 18, 2001
Posts: 30
Hai All,

Can anyone explain me what is session objects.

Thanx
sudha
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Hi,
Imagine yourself as the Bartender of this forum and people kept asking you questions, except, nobody is giving you their names. You wouldn't be sure who is asking what.
It would help to remember who is who if you can somehow give a unique token to each guy who posts a question. Then, when he comes back, he can show you the token you gave him, and since it's unique, you know exactly who he is. You can recognize him now.
HTTP is a stateless protocol and basically, a client makes a request, the server responds, and then that's it. If the same client makes a second request (like, clicking "Refresh", or whatever), the server has no way of knowing it was the same client before.
Unless the server gives the client a token.
A session object is an abstraction of this "token". It's the servlet's way of maintaining state (in the form of attributes) in a stateless protocol. In cruder terms, you can imagine a session object as a "shopping cart" of data that you load/unload (or more correctly bind/unbind) with setAttribute()/getAttribute() methods, as your client navigates through the JSPs and servlets of your web application.
For more information, I recommend you check the methods of the javax.servlet.http.HttpSession class in your Servlet API docs.
-anthony
aftab lal
Greenhorn

Joined: Mar 23, 2002
Posts: 2
=============
when your servlet executes code
HttpSession ses=request.getSession();
The container creates the session object which
will only be available when you are using the
same browser and when you execute this servlet
by opening another browser new session object will
be created so session object is bind to browser.
==========
And you can place objects in HttSession Object by
sess.setAttribute("users",new Vector());
so it gives more controll over servlets.
=========
please can anyone correct me if i am wrong.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session objects
 
Similar Threads
size of objects in session
Jsp to Jsp Communication
What is in the Session?
Where do Session objects live??? Server or Client??
How to share session among web applications