On Wed, Jul 9, 2014 at 12:48 PM, Marko Asplund <marko.aspl...@gmail.com> wrote:
> On Wed, 09 Jul 2014 07:23 Martin Grigorov wrote: > > > > ... > > > try { > > > response = (HttpServletResponse)asyncContext; > > > > > > > Maybe it is implementation detail that this cast works but usually you > have > > to use > > > > http://docs.oracle.com/javaee/6/api/javax/servlet/AsyncContext.html#getResponse() > > to get the response > > This was one of the things I was wondering about: calling > AsyncContext#getResponse() returns a ServletResponse instance that doesn't > implement the HTTP protocol specific sendError etc. methods. > Casting ServletResponse to HttpServletResponse is OK most of the time. You can check with "instanceof" before doing the cast. But casting AsyncContext to HttpServletResponse is way too brave. > > What would be the correct way to return an error response (including HTTP > status code) to the client in this case? > > > marko >