This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
============= 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.