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.
I wonder how I am getting session object all the time I guess It should be null because I have specified FALSE in the request method, but still I always get session object.
So is it like an implicit session object is always created for JSP no matter we use it or not.
The "why" is asking why do you care if there is a session or not? If you don't want to answer, that's up to you.
Gurdershan Singh Bagga
Joined: Oct 02, 2008
The reason I care about is because I am using a Sessionlistner in my application and for any exception I am invalidating the session and then redirecting it to the error jsp.
Now this error.jsp again creates a session object that is caught by sessionCreate event in my listner. On session create event I am assigning some resources to the user so what happens is that when some exception comes I snatch some resources and the same amount of resources are again given to this useless session.
I had a workaround that checks session.isNew() before assigning resources but I just want to know that can I stop creation of session object when I am redirecting to error.jsp.
If you remember, there is a page directive for the JSPs
amongst other things, if you have not mentioned this attribute for page in the JSP, by default session is activated for the JSPs, so even if you do request.getSession(false) in the code, it won't matter, because session object is already associated with your JSP (implicit object). So if you do not want the session then use the directive listed above.
If you could explain what kind of resources you are associating with the user, I might be in a better position to discuss a better work-around with you for the problem.
Never Remember the failure
Never Forget the mistake