• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem caused by pressing the 'BACK' button on the broswer

 
chiu pong
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I have a question about the problem caused by pressing the 'BACK' button on the broswer.
Suppose i have 3 pages, namely a.jsp, b.jsp and c.jsp.
a.jsp contains a form for user to enter some information and its action page is b.jsp.
b.jsp will collect the information from a.jsp and insert it to the database and then redirect to c.jsp.
c.jsp is just a notice page. However if the user press the 'BACK' button on c.jsp, it will cause the b.jsp to insert the data again.
So how can i handle this situation? Is it an usual way to set a session in a.jsp and invalidate it at the end of b.jsp?
thx for reply.
cheers,
ypc
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never do it this way. Firstly yu have to use the MVC (Model, View, Controller architecture)
There are two Controllers, A and C (following your naming)
The user requests 'A' via a 'GET' request, they are shown the view 'a.jsp'. 'a.jsp' POSTs back to A.
Back in 'A', it resonds to the POST by processing the request and using sendRedirect() to 'C'. 'C' responds to the GET request by showing the view 'c.jsp'.
If the user hits the back button, it skips the POST since there is no view and goes back to the GET 'A' request. The data is not resubmitted.
Try this at home
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic