I was writing a filter, which would check the if the user is
authorized and only then redirect him or her to the traget service to
get rid of auth check in each servlet. When I start development server
I get the following exception : "java.lang.ClassCastException:
org.mortbay.jetty.Request cannot be cast to
javax.servlet.http.HttpServletResponse".
My filter method looks like this :
@Override
public void doFilter(ServletRequest request, ServletResponse
response,
FilterChain chain) throws IOException, ServletException
{
HttpServletRequest httpReq = (HttpServletRequest) request;
HttpServletResponse httpResp = (HttpServletResponse) request;
HttpSession session = httpReq.getSession();
httpReq.setCharacterEncoding("UTF-8");
httpResp.setCharacterEncoding("UTF-8");
httpResp.setContentType("application/json");
Boolean isAuthorized = (Boolean)
session.getAttribute("isAuthorized");
if (!isAuthorized || isAuthorized == null) {
httpResp.sendError(HttpServletResponse.SC_UNAUTHORIZED);
} else {
chain.doFilter(request, response);
}
}
As far as I remember such approach should work fine. Why does it fail
in my case?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.