To whom it may concern,

[EMAIL PROTECTED] wrote:
> I've apache 1.3.36 + tomcat 4 + mod_jk 3.3

Something is wrong with that mod_jk version, by the way. The most recent
release of mod_jk is 1.2.23.

> I'm very new to web servers. I have a problem with the
> cache configuration of a tomcat web application. Using
> a http headers inspector, I can see that no cache
> control is been sent. 

Cache-control headers are usually not sent unless they are necessary.
Are you sure they are necessary for your environment?

> I'd like to send "CacheControl: no-cache" in the
> header of every page of my app. First of all, is this
> something that I should configure in apache, in tomcat
> or in mod_jk???

I'm sure there are other ways to do this, but in Tomcat, you can do it
easily by writing a simple "Filter" and installing it in your
application. Writing a filter is as simple as writing a class that
implements javax.servlet.Filter (3 methods) and then installing it by
adding this to your WEB-INF/web.xml file:

    <filter>
        <filter-name>encodingFilter</filter-name>
        <description>
            A filter to ensure that the request has a valid
            character encoding. This fixes problems when the request is
            being sent in (say) UTF-8 but the user agent doesn't specify
            the encoding.
        </description>
<filter-class>org.childhealthcare.diagnosis.servlet.EncodingFilter</filter-class>
    </filter>

This stuff goes right at the top of the web.xml file, just inside the
<web-app> element. Note that filters are applied in the order they
appear in web.xml, so you might want to familiarize yourself with any
existing filters before you install this one.

The method you'll want to look for when implementing your filter is
HttpServletResponse.addHeader(). You will probably want to add your
header /before/ you hand-off processing to the next filter in the chain.
Please please /please/ read the documentation for Filter.doFilter before
you get started. You can find this documentation here
(http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/Filter.html)
as well as other places, I'm sure.

Hope that helps,
-chris

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to