Re: Java Framework for Content Negotiation

On 20 May 2010, at 10:49, Angelo Veltens wrote:
> I am just looking for a framework to do content negotiation in java.

There's a reasonably stable and well-tested implementation that is  
used both in the Pubby and D2R Server codebases. See here:
http://d2rq-map.cvs.sourceforge.net/viewvc/d2rq-map/d2r-server/src/de/fuberlin/wiwiss/pubby/negotiation/

This just does the negotiation part (that is, matching an HTTP Accept  
header against a list of media types that the server supports,  
including support for q values). It only supports media type  
negotiation, there's nothing for language negotiation or encoding  
negotiation in there.

The package works like this: You configure a ContentTypeNegotiator  
with the media types supported by your app. Then you use its  
getBestMatch(...) method to determine the best response for a given  
request. The PubbyNegotiator class has a pre-configured negotiator for  
a server that supports HTML and various RDF syntaxes.

Best,
Richard


> Currently I am checking the HttpServletRequest myself quick&dirty.  
> Perhaps someone can recommend a framework/library that has solved  
> this already.
>
> Thanks in advance,
> Angelo
>

Received on Thursday, 20 May 2010 17:13:52 UTC