In servlet it says to allocate a new session object to the request if there is no session object corresponding this request. How would we do this in JSP ?
In servlet it says to use the already existing session object corresponding to this request, in case not present, do not allocate a new session object to this request. How would we do this in JSP ?
I see what he is saying in a way I guess. I have been trying to learn the same thing. Bear I know exactly what you mean. For me personally, when I create a session from a servlet and render the response to the JSP the JSP was sent the session object. That starts the session.
For me, when I click a link like 'contact us' (not involving a servlet) - (just linking me to another JSP page and go back) the session is forgotten.
When on a JSP, and going from one page to next without any servlet mapping, how would you keep that Session?
ALSO if there was mapping to a servlet, would I need to do (request.getSession();) in every single servlet?
I am not sure but to the original poster in this topic, that may help clarify your issue. I am possibly having the same one.
The point is that you don't need to do anything. Everyone seems to over think managing the session and usually just end up gumming up the works. Let the container manage the session and no one gets hurt.
Jeremy McNally wrote:How would you ensure they are in the same web app context?
By making sure that the context is deployed correctly. Sometimes people just copy stuff into the webapps folder rather haphazardly, or stick stuff into another web app (like ROOT), and all heck breaks loose.
Or, (self-fulfilling prophecy) by trying to micro-manage the session, they end up boofing things up.
Joined: Feb 21, 2014
I do sort of understand. I will be checking this out a little further. If I still don't get it after my research and trials I will post my own topic on it with example issues. Thanks again Bear.