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.
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 ?
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."