users@jersey.java.net

intercept 404 with client filter

From: Florian Hehlen <Florian.Hehlen_at_imc.nl>
Date: Thu, 23 Sep 2010 11:12:18 +0200

Hi,

I have an api where we want to return null whenever something is not found on the server. With the jersey client I have found 2 conceivable ways to do this


- Wrap all the WebResource.get() calls with some exception handling to handle the possible 404s

- Add a ClientFilter that can somehow transform the response.

The first is ok but not elegant.... Plus I will have to touch a lot of code :(

The second is appealing... but I am not sure how to do it. It's easy enough to intercept a 404 but then is there something I can set in the response which will result in a null value being returned by the get() call?

Cheers,
Florian

________________________________
The information in this e-mail is intended only for the person or entity to which it is addressed.

It may contain confidential and /or privileged material. If someone other than the intended recipient should receive this e-mail, he / she shall not be entitled to read, disseminate, disclose or duplicate it.

If you receive this e-mail unintentionally, please inform us immediately by "reply" and then delete it from your system. Although this information has been compiled with great care, neither IMC Financial Markets & Asset Management nor any of its related entities shall accept any responsibility for any errors, omissions or other inaccuracies in this information or for the consequences thereof, nor shall it be bound in any way by the contents of this e-mail or its attachments. In the event of incomplete or incorrect transmission, please return the e-mail to the sender and permanently delete this message and any attachments.

Messages and attachments are scanned for all known viruses. Always scan attachments before opening them.