• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

dynamically send user back

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic