[webkit-dev] Safari & Correctly Setting No-Cache via HTML

David D. Kilzer ddkilzer at kilzer.net
Fri Nov 2 09:21:35 PDT 2007


[Please reply off-list as this is off topic.  I thought I'd post to the list in
case anyone wanders across this thread via Google search looking for an
answer.]

Richard Glaser <richard at scl.utah.edu> wrote:

> Ok, this is really off-topic, but maybe someone has info on setting  
> JBoss 3.0 to add attributes to the HTTP header for no-cache with Safari.
> 
> Here is feedback for a developer for our ARC system using Horizon,  
> which we are using Safari, but works fine with FireFox & IE.

Using an Apache web server as a "reverse proxy" in front of your JBoss 3.0
application server is certainly one possibility, but it can be a bit tricky to
configure.  (Note that if you have multi-level firewalls that create a DMZ,
it's best to place the Apache web server/reverse proxy in the DMZ, and the
JBoss application server behind the second firewall.)

Your other alternative is to write an HTTP Filter and add it to the web.xml
config file for JBoss.  This requires that JBoss 3.0 (or whatever Java
application server you're using) implement the Java Servlet 2.3 (or newer)
specification [1].

[1] http://java.sun.com/products/servlet/download.html#specs

According to the documentation I found online [2], JBoss 3.0 implements both
Servlet 2.2 and Servlet 2.3 specifications.  I'm not sure how to switch between
them, but you'll want to enable the Servlet 2.3 mode.  (It may be as simple as
using a different web.xml config file that contains a Servlet 2.3 DTD at the
top and conforms to the 2.3 format.  Don't just change the DTD at the top of
the file and expect it to work, though!)

[2] http://labs.jboss.com/jbossas/docs/  (search for "3.0" on the page)

The javax.servlet.Filter class has a fairly simple API [3].  Within the
doFilter() method, you (safely) cast the ServletResponse object to an
HttpServletResponse object, the call the addHeader() or setHeader() method [4]
on the response object to add your (anti-)caching headers.

[3] http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/Filter.html
[4]
http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/HttpServletResponse.html

Here are some good OnJava.com articles [5,6,7] that should give you more
background on filters.  In fact, article [7] is pretty much exactly what you
want to do since it allows you to add HTTP headers to outgoing responses.

[5] http://www.onjava.com/pub/a/onjava/2001/05/10/servlet_filters.html
[6] http://www.onjava.com/pub/a/onjava/2003/11/19/filters.html
[7] http://www.onjava.com/pub/a/onjava/2004/03/03/filters.html

Note that if you have a Java application server that implements Java Servlet
2.2 or older, your only option is to create a wrapper class for
javax.servlet.http.HttpServlet [8] that basically does the same thing as the
filter would do (adds/sets HTTP headers) for outgoing responses.  This is a
little more involved, but works just as well (assuming you don't have too many
filters that you wanted to use).  In terms of software patterns, this is the
Adapter Pattern [9,10].  Your new servlet would also be specified in the
web.xml config file for the application server.

[8]
http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/HttpServlet.html
[9] http://en.wikipedia.org/wiki/Adapter_pattern
[10] http://c2.com/cgi/wiki?AdapterPattern

Again, please reply off-list if you have additional questions.

Dave




More information about the webkit-dev mailing list