Monday, February 15, 2010

Sending HTTP Error Response from JAX-RS Method

Whether you use Apache CXF, Restlet, or Jersey, JAX-RS (JSR-311) gives you a standard way of sending RESTful HTTP Response with error status code.

All you need to do is throw You don't have to change the method signature, you can still return the normal domain class when the method is successful.

 public SessionResource getSession(@PathParam("id") String id) {
  try {
   // ...........
  } catch (IllegalArgumentException e) {
   throw new WebApplicationException(e, Status.NOT_FOUND);
That's it!

1 comment:

polo outlet said... Burberry Outlet Air Max Shoes Coach Black Friday Coach Black Friday Coach Cyber Monday Coach Factory Coach Outlet Factory Coach Outlet USA Coach Purses Factory Coach Purses USA Coach Store Outlet Coach Purses On Sale Monster Beats Outlet Louis Vuitton Outlet Louis Vuitton Factory Marc Jacobs On Sale MCM Outlet MCM 店铺 cheap oakley sunglasses Michael Kors Outlet Michael Kors Outlet Michael Kors Factory Michael Kors Outlet Michael Kors Factory Online Coach Factory Outlet North Face Outlet Online Polo Outlet Store Ralph Lauren UK Sac Longchamp Pairs Coach Outlet Online Coach Factory Oultet Barbour Jackets Outlet Online Canada Goose Outlet Gucci Outlet Online Michael Kors Outlet Moncler Clearance Moncler Jackets Outlet Online North Clearace Outlet Polo Ralph Lauren Outlet Online Woolrich Clearance Michael Kors Factory Outlet Coach Outlet Online USA Beats by Dre Coach Purses Outlet Online Michael Kors USA

Post a Comment

Copyright 2009 Spring vs Java EE Web Dev. Powered by Blogger Blogger Templates create by Deluxe Templates. WP by Masterplan