This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to deal with page refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "how to deal with page refresh" Watch "how to deal with page refresh" New topic
Author

how to deal with page refresh

Blood Bigsoon
Greenhorn

Joined: Jun 03, 2001
Posts: 13
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

Joined: Jun 03, 2001
Posts: 6
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

Joined: Jun 03, 2001
Posts: 13
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

Joined: Jan 07, 1999
Posts: 6913
"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.


A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how to deal with page refresh
 
Similar Threads
REFRESH A JSP PAGE
How can I update web page or part of web page without using <meta http-equiv="refresh" >
Refreshing a jsp page
how to display time in jsp page
update page content