users@jersey.java.net

[Jersey] Re: Question about returning 404

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Fri, 11 Oct 2013 10:27:38 +0200

On Sep 20, 2013, at 2:10 AM, Rawat <geegalrawat_at_gmail.com> wrote:

> Hi All,
>
> I am using Jersey 1.14 and in my Servlet POJO i am trying to return 404 to the client

You cannot throw JAX-RS exceptions from a Servlet and expect it to get processed properly. You can only throw it from JAX-RS resources or providers.

Marek

>
> if(respMap == null) {
> throw new WebApplicationException(new Exception("No data found"), 404);
> }
>
> But client received 500. Can anyone copy paste some sample code to return a standard http status code ?
>
>