By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,571 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,571 IT Pros & Developers. It's quick & easy.

Why is Tomcat caching content for six seconds?

P: n/a
Hi,

I have a JSP application on Tomcat that performs XSL transformations on
an XML file using the xtags-1.0 taglib. Basically, I have an 'edit' page
that displays a table of entities from my XML file. Each row has a link
to a 'delete' page that removes the row from the XML file itself and
then forwards back to the edit page to display the updated table.

My problem is that the deleted row is displayed when the edit page
reloads. A copy of the XML file is apparently cached on the server for
about six seconds. The XML file itself written immediately to disk, but
I can hit my browser's refresh button any number of times within those
six seconds and I only ever get the cached copy. This occurs on both my
edit page and the direct URL to the XML file. After six seconds (with or
without any intervening browser reload attempts), the updated content
becomes available on the Tomcat server and the next reload attempt
produces the desired result.

I have discounted the possibility of browser caching and I have tried
various Tomcat configuration options without success.

I'm running Tomcat 4.0.6 on Linux 2.4.20 under the NetBeans 3.5 IDE and
using Mozilla 1.3 for the browser. I have also experienced the same
behavior with Tomcat 4.1.24 (no NetBeans) on both Windows and Linux. My
JSP sources are attached.

What's going on here? Is there any way that I can invalidate Tomcat's
cached instance of the XML content or otherwise force it to reload the
file from disk? Any suggestions greatly appreciated.

Steve

--- delete.jsp ---

<%@ page contentType="text/html" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/xtags-1.0"
prefix="xtag" %>

<xtag:parse uri="/config/events.xml" id="eventList"/>
<xtag:remove select="//*[name()='Event' and
@identifier=$param:identifier]"/>

<%
String fileName = "/home/adams/myapp/web/config/events.xml"
FileWriter output = new java.io.FileWriter(fileName);
eventList.write(output);
output.close();
%>

<jsp:forward page="edit.jsp" />

---
--- edit.jsp ---

<%@ page contentType="text/html" %>
<%@ taglib uri="http://java.sun.com/jstl/x" prefix="x" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<c:import url="http://localhost:8081/config/events.xml" var="xml"/>
<c:import url="http://localhost:8081/config/events.xsl" var="xsl"/>

<x:transform xml="${xml}" xslt="${xsl}">
<x:param name="doEdit" value="true"/>
</x:transform>

---

Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.