ETag Filter ver. 1.4

This is a Java servlet filter (as per Servlet API 2.3). ETagFilter lets you deal with ETag headers in HTTP requests. As per the HTTP protocol spec ETag is the "entity value for the requested variant". So ETag is HTTP request header defines some token that can be associated with the requested web resource (your html, JSP, XML page etc.).

ETags could be used in conjunction with the "If-None-Match" header in order to take advantage of the client's (browser's) cache. At the first step (first request) our server can generate ETag value for the requested resource and return in during the normal response. Browser will cache the response and the associated ETag value. During the sub-sequential requests browser will send that ETag value back to the server. Server will examine the ETag. As soon as it will be determined that the requested page hasn't changed since last time the same client requested it, server will send back a status code 304 (Not Modified) with an empty body. This trick lets you save a lot of bandwidth.

So this filters uses MD5 hash calculation for setting/checking ETag headers.

How to use it:

a) download etagflt.jar and save it in WEB-INF/lib

b) describe this filter in web.xml


Also you may exclude some of your files from the processing. Parameter exclude contains a commas separated list of files excluded from the processing. E.g.:


By default this parameter is empty (do not exclude files).

c) describe a mapping for this filter in web.xml


in this case filter will be on for the each .htm file

And now when your client request .htm file from your site this filter will proceed them with ETag.

    For downloading:   etagflt.jar

 ©  Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.


Also in JSOS: