Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamically send user back

 
gaurav chaudhary
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made one html which takes data to a servlet which finally inserts it into database. But if any error occurs in the servlet(flow goes within the catch statement), then browser should automatically go back one page to html where form is there with all values entered in the form(same function which we do by pressing browser's back button.). chaudharygaurav@yahoo.com
 
Thomas Goorden
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming you get exceptions when a user enters incorrect information (text where you expect an integer perhaps?).
The proper thing to do is to catch the exception and use the information the user supplied to build a new page with some extra information in it.
If you really want to redirect a user (the user will lose the information he/she has entered!), it might be possible to get the "referrer" from the HTTP request header and do a response.sendRedirect on that. However, this will probably just send them back to an empty form without any information on what happened. (plus, you don't always get a referrer from the browser)
Hope this helps,
Thomas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic