I am not sure if this is more appropriate for the user list, I will rely on the new
moderator to redirect it as he sees fit (thank
you).
I am implementing a custom valve that adds some information to inbound requests. I've
noticed a strange behavior as follows:
Certain calls on the HttpServletRequest object seem to cause the request processing
chain to fail--the request is never delivered to
the appropriate servlet, and Tomcat returns a well-formatted, but blank, HTML page to
the client.
The following calls cause this behavior:
getServletPath()
getSession(boolean create)
getContextPath()
The following call _does_ not exhibit this behavior--the request is distributed
properly:
getRequestURL()
For example, the following code snippet causes the failure:
public void invoke(Request request, Response response, ValveContext context)
throws IOException, ServletException {
if (!(request instanceof HttpRequest) ||
!(response instanceof HttpResponse)) {
context.invokeNext(request, response);
return;
}
String reqPath=((HttpServletRequest) request.getRequest()).getServletPath();
if (reqPath.equals("/login")) {
// do nothing
context.invokeNext(request, response);
return;
}
// do actual work
context.invokeNext(request, response);
}
If I replace the call to "getServletPath()" with "getRequestURL()", the request is
processed properly.
Is this a bug? Are their certain "illegal" calls on the request object that break the
valve chain?
My work around for now is to parse the requestURL myself rather than using the
convenience functions, but I can't find a work around
to not being able to access the Session.
Thanks in advance for any help.
- Jeff Wishnie
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>