File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes REFRESH A JSP PAGE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "REFRESH A JSP PAGE" Watch "REFRESH A JSP PAGE" New topic
Author

REFRESH A JSP PAGE

ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
I am trying to update a record in a JSP page which first fetch record from database, you make the relevant changes and on submit , It updates the record in the database. Now the problem is when I load this JSP page and ask it to show the specific record , It is showing the same old values as good as the previous JSP page.
I have performed the query on the database and found that changes have been updated. This seems to be a problem in refreshing the JSP page. Can someone tell how to refresh a JSP page ?


SCJP, SCJD, SCWCD, SCBCD, SCEA
Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
Use some event on which u want to refresh your page
and on that javascript event call method
history.go(0)
and browser will refresh your JSP page
hope it helps


SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
ravindra janapreddy
Ranch Hand

Joined: Jan 30, 2001
Posts: 84
Dear Gaurav,
Thanks for the reponse.
I have tried to invoke the function in which I have embedded history.go(0) in onLoad event of the body tag.
The partial code is as follows :

function Refresh() {
history.go(0);
}

</script>
</HEAD>
<BODY BGCOLOR="F0FFFF" TEXT="00BFFF" onLoad="javascript:Refresh()">
Now, When I tried to load this jsp page it seems to go in a infinite loop kind of situation. I think , What is happenning that when body is getting loaded it invokes history.go(0) and It calls itself again which again loads the body which again invokes the javascript function and so on and so forth. Have I gone wrong somewhere. I have got only submit, reset and a back button in this JSP page. So the only way , I can refresh this JSP page is when it is getting loaded . Is there some other event which you can think of in which this javascript function Refresh() can be called ?
regards
Ravindra

SCEA, SCBCD, SCWCD, SCJD, SCJP
ravindra janapreddy
Ranch Hand

Joined: Jan 30, 2001
Posts: 84
My problem is quite similat to the problem faced by Sanjay Patel. He has also posed a similar question in this forum. Please refer to it as well. The problem will be clearer.
vikinsa
Ranch Hand

Joined: Apr 18, 2001
Posts: 46
I am sorry to say that calling any refresh function on body onLoad will not help much. It may rather increase the difficulty levels. Because every time the page gets loaded it gets refreshed by that function and again the page is loaded and again the function is called and.... this process goes into the infinite loop.
Try using <%response.setHeader("Cache-Control","no-cache");%>
in your JSP before anything. Place this code before anything in JSP on the top at line number 1. It might help. I hope.
------------------
Vikas Aggarwal
Technology Associate
http://www.vikinsa.com


Vikas Aggarwal<BR>Technology Associate<BR>http://www.vikinsa.com
 
 
subject: REFRESH A JSP PAGE