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, I believe session object is shared across several servlets running in the site. I am running my application in an environment where several servletcontext exists. Does the session object created in one servlet can be accessed in other servlet contexts ? To make my question clear, i have given the following eg: (say) www.xxx.com is a free hosting provider. For each user a Separate servlet context is assigned. Say there are 2 users with their application running as: www.xxx.com/A/app1 and www.xxx.com/B/app2. can a sessionobject created by user A accessed by user B Please explain. Thanks in advance. regards samkar
I believe session object is shared across several servlets running in the site. This stmt is only partly true. To my knowledge, A sessions obj can be shared across several servlets running in the site which belong to the same session. So obviously two users will not be able to share the same session right!. Also if allowed, the same user can start more than one session and still the objs' cannot be shared because they belong to different sessions though the user is same. This is what is known as Session Management. The link will take you to the jGurus' JSP tutorial and in particular to the Session Mgmt topic. It should be same as servlet since JSP is ultimately promoted to a servlet. Hope this helps. Regds. - satya
[This message has been edited by Madhav Lakkapragada (edited September 24, 2000).]
Hi Paul, Infact i have used my proper name only. My first name is : Sankar My family name is : Subbiramaniam. As it is too long i have just given my initial (first letter of family name). Hope it clarifies. regards Sankar
Joined: Nov 22, 2008
Hi Madhav, Please explain me how a session object is created ? How does a Servlet container deteremine whether a session already exists ?
I went thru the article you mentioned still my doubt is not clarified: AS per the article session objects are stored in servlet container. In an environment like free servlet hosting, is it not the servlet container common for all the users ? This is what i understand: Browser detects that call to url www.xxx.com/A/app1 is for the first time. So it doesnot have already a cookie stored in it. Sends in its Request object just the url www.xxx.com/A/app1. Servlet creates a session object, puts in the servlet container and sends the session id back to broser via Response object. Next time when browser sends a request to wwww.xxx.com/A/app1, it sends the session id also. My question is, say from the same computer, same browser session if a request is made to url www.xxx.com/B/app2, will it send the session id or not ? I would like to know how the browser differentiates the call made to different applications in different servlet context, but with in the same url. I hope i have expressed myself clearly. regards Sankar
Joined: Jun 03, 2000
My question is, say from the same computer, same browser session if a request is made to url www.xxx.com/B/app2, will it send the session id or not ? IMO, it will not. Since this is from a different URL/app, I guess it is treated as a different session. I would like to know how the browser differentiates the call made to different applications in different servlet context, but with in the same url. Doesn't the req obj differentiate the two apps. I am not sure if I got you right... Anyone else have other/better ideas..... regds. - satya