Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Detecting if user clicks refresh  RSS feed

 
Michael ness
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Does anyone know of a simple way to detect if the user has refreshed a page. My problem is I have a web page that connects via jdbc to a database to insert data. After doing the insert it forwards to another page. However if the user then clicks refresh the insert is done again. I could probably write something to detect the duplicate insert but would prefer to detect the refresh and then not perform any database actions if it occurs.
Thanks
Michael
 
Debashish Chakrabarty
Ranch Hand
Posts: 231
Firefox Browser Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It could be achieved by using Javascript, but the better way would be to have some server-side check for duplicate entry and respond to user if he refreshes the page that his entry has already been inserted.
 
Michael ness
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply,
Do you know how to do it in javascript because ive looked and as far as Im aware it's not possible.
Checking for duplicates won't work in all instances for example I have a page that records an id and the submission date/time.This date/time is generated automatically. It is possible the id could be used many times with the only difference in the database being the date. If refresh was pressed after a save the id would be inserted again with a different date/time.
 
Maurice Biche
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope u r working in java based technology..
There is one j2ee pattern called token synchronization that precents the duplicate submission. Just read some document about 'Token synchronization' that will be helpful to u
 
V Srinivasan
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do Session management also, through that you can set one session can have one data to insert, something like that.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!