• 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

Form action - Refresh

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi All,

I have a JSP. Whenever, we submit the JSP and with all the fields filled, it inserts a new record in the DB.

Following is the form tag

<form name="Sorder" action="/sales/urn/show/maintain.do" method="post">

However, whenever the user presses the Refresh icon from the toolbar or does a right-click + refresh, it calls the action which inserts a new record in the DB. We want this not to happen i.e. whenever refresh is called, the action should not be performed.

Please if someone can guide me how to do this.

Thanks,
Nikhil
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you are looking for is the Post-Redirect-Get pattern

Basically when your servlet finishes the action to insert the record to the DB, you redirect to the result page rather than forward to it.
That creates a new request.

If they then refresh that page, they just refresh the "get" part, not the save.

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This article might also be helpful.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic