aspose file tools*
The moose likes JSP and the fly likes refresh problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "refresh problem" Watch "refresh problem" New topic
Author

refresh problem

feng fu
Greenhorn

Joined: Feb 24, 2004
Posts: 8
I have a List Student page and a update page, everytime I updated, I use response.sendRedirect("ListStudent.jsp") back to the List Student page, but I have to click refresh button, then the record on the page changed, what I should do to make it automatic refresh? Thanks
Shankar Narayana
Ranch Hand

Joined: Jan 08, 2003
Posts: 134
Hi,
Try using request.forward(<url> instead of response.sendRedirect..


"Failure is not when you fall down; its only when you fail to get up again."
Seetesh Hindlekar
Ranch Hand

Joined: Feb 13, 2004
Posts: 244
Hi,
Alternate soln could be
U could also use the meta tag of ur where the page is refreshed every n secs.
http-equiv="refresh" content="60" in the meta tag.
Rgds,
Seetesh
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

You don't need to force the page to refresh, what you need is to prevent it from being cached in the first place. That's been discussed more times than I can count, so please do a search for this issue.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
feng fu
Greenhorn

Joined: Feb 24, 2004
Posts: 8
I am sorry, but "request.forward<url>" doesn't work. It gives me a tomcat error. And I used <meta> before, it only refresh every one miniute. I think that is not what I want, I want it just refresh when List Student page is re-opening
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

Please re-read my reply. You do NOT need a refresh. The browser is pulling up your old page from the cache. What you need to do is to prevent the page from caching.
feng fu
Greenhorn

Joined: Feb 24, 2004
Posts: 8
I found these code about prevent reload the page from cache
"response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma", "No-cache");
response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-cache");
" where should I put it? Could you tell me what I should do, thanks
Winston Smith
Ranch Hand

Joined: Jun 06, 2003
Posts: 136
Just put the code at the top of the JSP page:


for (int i = today; i < endOfTime; i++) { code(); }
feng fu
Greenhorn

Joined: Feb 24, 2004
Posts: 8
I used the code you give me, but it didn't change, I still need to click refresh. It that mean it is not because of the cache?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

If you are sure that you are sending the new data to the page after the update (are you?) then if it is showing the old data, you have a cache problem. It is possible that your problem lies in code logic, but that isn't borne out by the fact that a refresh brings up the new data.
 
jQuery in Action, 2nd edition
 
subject: refresh problem