• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session problem, should I invalidate the session?

 
Stephen Wei
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all, I am having a problem with the session subject, can someone help please?

In short, I am created a JSP page(start.jsp), which initialize the session. User will input many things in this page, and submit the results to my servlet. Then My servlet process the request, and forward it to the finish.jsp . At last, finish.jsp will do sth like:
session.invalidate() to end the session. finish.jsp is returned to the user.
The problem I found is that with above approach, when user submits the message and sees finish.jsp, user use "back" link to go back to the start page, and submit the message again, this repeat many times. I found that if user keeps doing this , the message data got corrupted, and become garbage on the server side.
What I did is that I also write
<%@ session = true %>
...
session.invalidate();
in my start.jsp, so I invalid the session at the start.jsp page, and let my servlet to create the session. This way, no matter how user use back button, the data is always submitted correctedly.
But I do not understand why. Can someone help to explain?
Thanks.
 
prashant parab
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your start.jsp page should only create the session.In your servlet u should write request.getSession(false) to take the session object.
I think u r making session(true) in some wrong place .check your code
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!