2

My action is inserting data from form into the database.

Now my problem is every time, user hits "refresh" button of browser, the action class is called with existing data and fresh new entry with the same database is made.

Is there any way to get refresh just refresh the data rather than calling the action class? or at the minimum prevent 'refresh' on the page?

Shreyos Adikari
  • 12,348
  • 19
  • 73
  • 82
chakri
  • 629
  • 3
  • 11
  • 21

3 Answers3

3
You have to use saveToken() method in action class and reset token values. which is available in Struts
Suresh U
  • 463
  • 3
  • 14
1

You can use struts tokens- Prevent Duplicate Submission

http://www.techfaq360.com/tutorial/multiclick.jsp

and Always check for duplicate in database

Vishnu V.O
  • 11
  • 2
0

I'm not sure if this is what you're looking for but see if serves as a starting point: http://www.whoopis.com/howtos/jscript-refresh-save.php

As for the database entry problem, that should be taken care by your primary key of the database. If there's a pre-existing value for the same primary key, you shouldn't update!

zEro
  • 1,255
  • 14
  • 24