• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

session objects

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai All,

Can anyone explain me what is session objects.

Thanx
sudha
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
=============
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.
 
This one time, at bandcamp, I had relations with a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic