Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

refresh resends request as url does not change.

 
george justin
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
For saving some data entered in initial.jsp I call save.jsp which does the necessary save and returns to the initial page through a forward to initial.jsp.
However the url still stays at save.jsp and a click on refresh button of browser resends the info and creates duplicate records in DB.
I dont want to use send redirect and I dont want to use javascript to disable refresh button.
I wqant the url to reflect initial.jsp after the save so that refresh does nothing....
can somebody help me out.....
thanx,
fred.
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you put something in session -- a boolean flag maybe? that's set to true once the record is entered, so that if they DO hit reload -- you first look for the flag, and if you find it -- you don't enter the thing in the DB.
'cause the thing is -- when you use .forward() the request happens within the app server -- so the URL displayed in the browser will not change. The only way to change it is to use the .sendRedirect() method... which you already said you don't want to do.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"fred flintstone",
Fictitious names are not allowed, sorry.
Please check out the naming convention at http://www.javaranch.com/name.jsp.
Please edit your profile and select a new name which meets the requirements.
I noticed you've changed your display name from a valid one to an invalid one. You should change it back quickly, since accounts with invalid names get deleted.
Thanks.
Dave
 
Lene Shen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
say, you saved the record in db with the method saveRecord().
<%
boolean isOK=saveRecord();
if(isOK){
%>
<html>
<header>
<META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.some.org/some.html">
</header>
</html>
<%
}else{
...
}
%>
----------------
is that ok?
 
george justin
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx jess and shane, I think both your answers should work.
and dave ..I have changed my name ..jus the way u want it.
cheeeers,
george.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!