aspose file tools
The moose likes JSP and the fly likes Is there a way to control Refresh click Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Is there a way to control Refresh click" Watch "Is there a way to control Refresh click" New topic
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
 
Threads others viewed
Download pdf file in struts2
Avoiding database insert/update on click of refresh button
Refresh in browser
Browser Refresh
Reload that JSP page once when an event performed on the file
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture