| Author |
Is there a way to control Refresh click
|
Suren Raj
Greenhorn
Joined: Jan 24, 2003
Posts: 8
|
|
Hi all, is there a way to control refresh click of the windows on a jsp file ? I dont want to disable it. The problem i faced is, whenever i do refresh (right-click and selected refresh or refresh from main menu) my JSP file submits the servlet with the last selected handle or button. Instead i would prefer having my own handle or prefrences.
|
 |
Scott Duncan
Ranch Hand
Joined: Nov 01, 2002
Posts: 363
|
|
|
I am thinking javascript is the best way to go for this.
|
No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
|
 |
Yuriy Fuksenko
Ranch Hand
Joined: Feb 02, 2001
Posts: 411
|
|
There is a J2EE pattern for that - you have some token on a page and in a session, and each request you compare them - works pretty fine to me. JavaScript can not really detect a reload until page is reloaded. Onunload event does not really helps with that.
|
 |
David O'Meara
Rancher
Joined: Mar 06, 2001
Posts: 13459
|
|
I agree with Yuriy Fuksenko but still not completely. My preferred solution if you are just protecting them from re-sumbitting data is to use sendRedirect to connect the pages rather than include or forward. ie client submits page, page is processed, sendRedirect is sent to client, forcing the client to re-request the page. This way a reload sends another request for the page rather than another re-submitting the data. It should be used sparingly since it involves two HTTP calls rather than one, but in practice it isn't too bad. Dave
|
[ JavaRanch FAQ ][ Book Promotions ][ DbTamer ][ BumperStickers ][ JavaRanch Badges ]
|
 |
Jignesh Patel
Ranch Hand
Joined: Nov 03, 2001
Posts: 625
|
|
David u are right. But in the case where we are forced to use forward or include then how do we maintain. Yuriy can u please give me a pattern name or link for avoiding of inserting new data in the database while page refresh.
|
 |
David O'Meara
Rancher
Joined: Mar 06, 2001
Posts: 13459
|
|
"Jignesh", We are light on rules at the JavaRanch, but the Naming Policy is one that we enforce. You need to edit your display name soon or your account will be deleted! Thanks, Dave
|
 |
Vikalp Singh
Ranch Hand
Joined: Dec 29, 2002
Posts: 50
|
|
you can do this by one more way, by disabling the control button by javascript and opening the browser with no header.
|
 |
senthil sen
Ranch Hand
Joined: Oct 10, 2002
Posts: 182
|
|
|
can anyone send a code for this solution?
|
 |
 |
|
|
subject: Is there a way to control Refresh click
|
|
|