jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes dynamically send user back Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "dynamically send user back" Watch "dynamically send user back" New topic
Author

dynamically send user back

gaurav chaudhary
Ranch Hand

Joined: Jun 24, 2002
Posts: 64
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


gaurav
Thomas Goorden
Ranch Hand

Joined: Aug 15, 2001
Posts: 39
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: dynamically send user back
 
Similar Threads
How to close a child window through the servlet?
using html or applet
servlet aliases are not working
can HTML page be displayed using servlet in app-serv communication
html file with multiple form elements