Content Negotiation Filter

Created: 2012/12/03 21:35:26+0000 Revised: 2012/12/24 17:27:59+0000 Revisions:  11 10 9 8 7 6 5 4 3 2 1

As part of the (limited) linked data I provide on this website I implemented a content negotiation filter to provide the 303 redirects. It is configured with an XML file that describes the possible variants. The content negotiation algorithm is based on the Apache Negotiation Algorithm but lacks support for the encoding and character set.

I implemented this myself because when I was trying to find out how I should do this I kept finding Paul Tuckey's UrlRewriteFilter and JAX-RS which uses annotations. The UrlRewriteFilter only supports string matching on the accept header and 302 redirects. JAX-RS and annotations had nothing to do with how I was implementing my website.

I used Maven as the build tool for this. Some of you may have heard me say that I prefer Ant and this is true. One of the problems I have with Maven is that the lifecycles make it unsuitable for persistent data stores, this does not apply here. What I like about Maven is the dependency management, which I usually take advantage of using Ivy. Ivy does support publishing to a repository but I felt that it would be more straight forward to use Maven and there wasn't anything I wanted to do that Maven would make difficult.

It is currently available from source control at BitBucket, It has also been released to the Maven central repository.

Group IDcom.mattunderscore
Artifact IDcontent-negotiation
Show all

I had intended to provide this as three artifacts but looking at Sonatype and the requirement to raise a ticket I will provide a single artifact. Two of the three artifacts aren't much of an end product. The Maven generated site is available at I am sure you will all be glad to learn that the next release will contain automated testing.

For those of you interested in linked data for this project, see here: