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

how to deal with page refresh

 
Blood Bigsoon
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
help me!
I had wrote a jsp to update my database .but each time the user refresh the jsp page,the update would invoke one time.how to prevent it?
 
HASIKA NANAYAKKARA
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I GUESS THAT U UPDATE THE DATABASE ON A CLICK EVENT OF A SUBMIT BUTTON;ASSUME THE CAPTION OF THE BUTTON IS "UPDATE" AND THE BUTTON NAME "btnUPDATE".TRY THE FOLLOWING METHOD.IT COULD WORK
<%
String BUTTON=request.getParameter("btnUPDATE");
if(BUTTON==null)BUTTON="NULL" ;
if (BUTTON.equals("UPDATE")){
://WRITE THE REQUIRED DATABASE UPDATE CODE HERE
://WITHIN THE IF CONDITION
}
%>
 
Blood Bigsoon
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but if the user refresh the page ,then the update sql will execute again,i had found a way:
<% response.setHeader("Expires", "-1"); %>
is it right?
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"bigsoon",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic