• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP Caching in Tomcat

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem with caching in my new servlet. Currenly I am using Eclipse and Tomcat for development. I noticed that when I request a page the page is compiled and instantiated. The page would get data from the database and display it. I would then goto a new page to update the data expecting the prior page to display it differently. When returning to the original page (without using the back button) the value displayed is the previous one even though it was changed.
I believe this is something to do with caching. I used the praga/no-cache and Cache-control/no-cache headers without avail.
Is this something relating to the fact that the servlet eclipse generates does not contain a getLastModified function? If this is the case how would I go about fixing it? Thank you in advance
I used IE5.5 for testing
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried:
 
Scot Meyer
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not tried that. Wouldn't the user get a Page Expired message if they chose the back button? Not that this is not desireable. Is this the normal procedure for situations like this? I would have expected that a user requesting a page (servlet) would not be cached but reran.
[ March 15, 2004: Message edited by: Scot Meyer ]
 
Scot Meyer
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just tried adding
<% response.setHeader("Cache-Control", "no-cache"); %>
<% response.setHeader("Cache-Control", "must-revalidate"); %>
<% response.setHeader("Pragma","no-cache"); %>
<% response.setDateHeader("Last-Modified",System.currentTimeMillis());%>
to my page response and this still didn't fix it. It's as though the servlet is not being called and the information is being cached in the web server. Is it possible that Apache is causing this?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First step would be to verify whether your servlet is being called or not. Otherwise, we're just guessing.
 
Scot Meyer
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok did some additional testing. The JSP is definately not being called when the page is requested a second time. It will be called if I hit the Refresh button. So I am guessing this is an Apache setting. Currently my httpd.conf file states that the file_cache_module, headers_module, and cern_meta_modules are not loaded. Thank again for any help
I meant Tomcat 5.0 not Apache.
[ March 16, 2004: Message edited by: Scot Meyer ]
 
Scot Meyer
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I loaded all the source for tomcat and steped through the page. It appears as though if on a page reload(refresh) the code is called. I put a breakpoint at the earliest point in the tomcat source of the Http11 connector. This is a step after the thread is created.
Whats intereting is if I hit the enter key or retype the url in the address bar the page is not requested again even if I set the caching headers (in the above post). So it must be that IE doesn't resumit a request if it thinks the page is exactly the same (When it obviously isn't)
Im sure I am overlooking something obvious.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there also a IE setting that controls caching,
Internet Options -> temporary internet files -> settings -> check for newer versions of the stored page.
 
reply
    Bookmark Topic Watch Topic
  • New Topic