users@jersey.java.net

Re: [Jersey] Any built-in for support for forcing media type with Uri elements like a path suffix?

From: jaxzin <Brian.R.Jackson_at_espn3.com>
Date: Sun, 16 Aug 2009 02:28:34 -0500 (CDT)

Thanks Craig,
Sounds like exactly what I¹m looking for. And I hear you about the caching
product. It is an unfortunate effect of when NIH meets ³it¹s good enough,
right?² :-)

Thanks again,
Brian

On 8/16/09 2:24 AM, "Craig McClanahan (via Nabble)"
<ml-user+51619-1612925812_at_n2.nabble.com> wrote:

> jaxzin wrote:
>> > So I'd like my resources to support path suffixes like '.xml' and '.json'
>> to
>> > make is simpler for users to choose their response format without needing
>> to
>> > set the Accept header properly. Is there anything similar built into
>> > Jersey such as a query param it looks for or something? I'm willing to go
>> > with an turn-key solution even if its differs from my path suffix idea.
>> Any
>> > other good ideas? I'd like to do it transparently without changes to my
>> > resource classes such as accomplishing it with a Provider implementation or
>> > some other configuration setting.
>> >
> I would probably look at implementing a Jersey ContainerRequestFilter,
> returning a modified ContainerRequest that adjusted the path to remove
> the suffix, and add an appropriate "Accept" header. Because this all
> happens before the request is mapped to an actual resource method,
> Jersey will take care of the rest of the problem for you, and you can
> use the usual approach of a @Produces annotation on your resource method
> to select the appropriate response, so you don't have to pollute every
> resource method in your application with a kludge to support this.
>
> Google "Jersey ContainerRequestFilter" for some blogs and mailing list
> threads on this topic.
>> > Thanks,
>> > Brian
>> >
>> > P.S. Another 'real world' reason I need to skip out on the Accept header is
>> > that our page caching solution is know to have trouble with caching
>> properly
>> > when requests to the same URL differ by the Accept header. (In case anyone
>> > was ready to reply "Don't do that") :-)
>> >
>
> Sounds like a good argument to scrap a caching solution that doesn't
> understand how HTTP actually works :-).
>
> Craig
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3452649&i=0>
> For additional commands, e-mail: [hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3452649&i=1>
>
>
>
> View message @
> http://n2.nabble.com/Any-built-in-for-support-for-forcing-media-type-with-Uri-
> elements-like-a-path-suffix--tp3452599p3452649.html
> To unsubscribe from Any built-in for support for forcing media type with Uri
> elements like a path suffix?, click here
> < (link removed)
> GVzcG4zLmNvbXwzNDUyNTk5fDExOTY5OTE0MDc=> .
>
>

___________________________________________
Brian R. Jackson
Staff Software Engineer
ESPN.com Fantasy Games
(860) 766-2511



-- 
View this message in context: http://n2.nabble.com/Any-built-in-for-support-for-forcing-media-type-with-Uri-elements-like-a-path-suffix--tp3452599p3452749.html
Sent from the Jersey mailing list archive at Nabble.com.