This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes Is it a good idea to invalidate a session or remove attribute  to save resource ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Is it a good idea to invalidate a session or remove attribute  to save resource ?" Watch "Is it a good idea to invalidate a session or remove attribute  to save resource ?" New topic
Author

Is it a good idea to invalidate a session or remove attribute to save resource ?

Artemesia Lakener
Ranch Hand

Joined: Jun 21, 2005
Posts: 162
I'm thinking that after I use "session" to carry objects among several JSP pages, after I reach the final result page, maybe I should do something like "invalidate" the session or just remove those attributes stored in session, this should free some resources everytime. But the consequence will be --- if I click "back" button to go back to the middleway page, and then click "submit" or "continue" button, I will not get any results because the objects have been removed by me, so I have to go back to the first page and restart everything. What do you experienced guys usually do ?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Are you having memory issues?
If not, I would let the sessions time themselves out.
You've already mentioned one problem with manually removing the objects.
Another is the extra code that you will have to maintain to do this.

Write your app for clarity, then profile it to find it's bottlenecks.
Once you've done that, you can start to optimize by changing things the things that will give you the most bang for the buck. Often, it's not where you think it will be.

As one of our esteemed oldtimers here often says:
"Premature optimization is the root of all evil."


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Is it a good idea to invalidate a session or remove attribute to save resource ?