Here is a simple code example that actually redirects using a WebApplicationException. That way, you can put this into your opinion or in your resource and just drop it every time.
URI uri2 = UriBuilder.fromUri(url).build(); Response response = Response.seeOther(uri2).build(); throw new WebApplicationException(response);
You can also simply return your resource either to the view or in response to a redirect:
@GET public Object getView(@Context HttpServletRequest req) { if (somethingBad()) { URI uri = UriBuilder.fromUri("/somewhere_else").build(); return Response.seeOther(uri).build(); } return new View(); }
source share