Hi William,
I think this is because we modified Jersey to call
HttpServletResponse.sendError for the case of a status code >= 400 and
no response entity. This is so that error page mappings defined in the
web.xml will work. Calling HttpServletResponse.setStatus will not
result in error page mappings. This is annoying!
Two solutions:
1) In your pre-action can you adapt the HttpServletResponse and
override the sendError so it calls setStatus?
2) When released upgrade to Jersey 1.2 and deploy the ServletContainer
as a filter. For filters sendError is not called.
You could try using Jersey 1.1.5.1 and deploy as a filter
anyway, it might work.
Can you verify if 1) works for you, that way we definitely know my
analysis was correct.
Paul.
On Apr 20, 2010, at 4:52 AM, William Zhou wrote:
> Hi Expert,
>
> I was using a http servelet filter in my Jersey application to
> something with pre and post actions. In that filter, I will add a
> header to response if it caught 401 response. This was working on
> Jersey 1.0.3.
> But after I upgraded to Jersey 1.1.3.1, the adding header does not
> work any longer. Here is the code snippet:
>
> public class HttpAuthFilter implements javax.servlet.Filter
> {
> ....
>
> public ServletResponse onFailedWith401(ServletResponse
> servletResponse)
> {
> ((HttpServletResponse) servletResponse).setHeader("WWW-
> Authenticate", BASIC + " realm=\"" + m_realm + "\"");
> return servletResponse;
> }
> }
>
> I do not prefer to use a ContainerResponseFilter. Please suggest
> what I need change for the Jersey upgrade.
>
> Thanks,
> William
>
>
>
>