Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

refresh problem

 
feng fu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try using request.forward(<url> instead of response.sendRedirect..
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
feng fu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just put the code at the top of the JSP page:
 
feng fu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic