tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <wbar...@wilshire.com>
Subject Re: 4.1.10: Bug in handling of custom valves?
Date Thu, 19 Sep 2002 18:55:07 GMT
Custom valves are invoked before Catalina has mapped the request at whatever
level you put it at in your server.xml.  This means that if you put it
inside of your Context declaration, then getContextPath should work, but
getServletPath won't.  Placing it any higher up, then getContextPath won't
work.

Unless you *really* need access to Catalina internals, I'd strongly
recommend using a Filter instead of a Valve.  They are functionally similar,
but you're state in a Filter is much easier to understand.  Also, using a
Filter means that you are not tied to one particular version of Tomcat (or,
even to Tomcat at all :).

----- Original Message -----
From: "Jeff Wishnie" <jeff@deluxebiz.com>
To: <tomcat-dev@jakarta.apache.org>
Sent: Thursday, September 19, 2002 11:35 AM
Subject: 4.1.10: Bug in handling of custom valves?


> 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
> jeff@deluxebiz.com
>
>
> --
> To unsubscribe, e-mail:
<mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:tomcat-dev-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message