users@jersey.java.net

Re: [Jersey] Using ContainerResponseFilters

From: Marsh Eric <emarsh_at_mac.com>
Date: Wed, 22 Sep 2010 18:15:25 -0500

Well, really not so much. I'd already found it and I'm not seeing where (in what file) to register the filters. Is that in web.xml? I went to the LoggingFilter java doc and tried to click through to the com.sun.jersey.api.container.filter link to try to learn more about the base class but the link is dead. At this point I don't understand how to associate the filter with a particular URL or even how to write the filter. Is it essentially a standard servlet filter? That's why I was hoping for a more in depth explanation.

On Sep 22, 2010, at 5:46 PM, Paul Sandoz wrote:

> Hi,
>
> Does the following help:
>
> https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/container/filter/package-summary.html
>
> ?
>
> Paul.
>
> On Sep 22, 2010, at 10:00 AM, Marsh Eric wrote:
>
>> Hello,
>>
>> I've spent a solid day on this problem and hope that someone can help me.
>>
>> I'm working on a Netbeans web services project that uses Netbeans' "Create Restful Web Services" wizards. I don't want to change the generated files unless it is absolutely necessary to do so because the database is being modified often and consequently I often have to regenerate the files and don't want to lose work that had been done to them.
>>
>> My project includes caching data downloaded from the iTunes store as per their instructions in the section of http://www.apple.com/itunesaffiliates/API/AffiliatesSearch2.1.pdf titled Cache Architecture. I'm trying to handle this by using a servlet filter before/after the Jersey web services and testing the response code after chain.dofilter(). If I get a 404 then I download the requested data from Apple and insert it into my database. At this point I would like to do a redirect/refresh/modify the response object/whatever so that I can return the new data to the client. I've pretty much hit a brick wall. At this point the response object has been marked as committed so I can't alter it do a redirect or anything else. I've tried using wrappers but it contains an internal CoyoteResponse that I can't get to and that's where it is marked as committed.
>>
>> Doing some more reading I see that Jersey has it's own filters and from what I read evidently it's legal to modify the response after Jersey has returned it to the filter. It describes how to register a logging filter at https://jersey.dev.java.net/nonav/apidocs/1.0.3.1/jersey/com/sun/jersey/api/container/filter/LoggingFilter.html. This isn't all that helpful to me - I could really use some more complete examples on how to create and use the filters, especially as part of a Glassfish EE 6 web services project.
>>
>> Are there any examples or tutorials available? Can anyone give me some tips or point me in the right direction on this one?
>>
>> Thanks,
>>
>> Eric
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>