tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <funk...@joedog.org>
Subject Re: Servlet Filter modifying RequestURL
Date Mon, 28 Jun 2004 21:35:03 GMT
Yes (Or at least the following which is used by DefaultServlet):
         // No, extract the desired path directly from the request
         String result = request.getPathInfo();
         if (result == null) {
             result = request.getServletPath();
         }
         if ((result == null) || (result.equals(""))) {
             result = "/";
         }

It seems like your writing everything to a static resource so instead of 
called chain.doFilter(...) just use a RequestDispather and forward to
"/sports/welcome" and skip the Filter chain

-Tim

Henrik Vendelbo wrote:

> I am trying to use a Filter for a bit of URL rewriting.
> 
> Although the request.getRequestURL() documentation states that changing the content of
the returned StringBuffer is an intended us, it doesn't seem to have much effect. The DefaultServlet
is still chosen to create a response. The context path is "/sports".
> 
> The following does not seem to do the trick, what am I doing wrong. If I need to use
a HttpServletRequestWrapper, will I have to overrid all path getters ?
> 
> Henrik
> 
> HttpServletRequest req = (HttpServletRequest)_req;
> 
> String uri = req.getRequestURI();
> 
> StringBuffer urlBuffer = req.getRequestURL();
> 
> if (uri.equals("/sports") || uri.equals("/sports/")) {
> 
> urlBuffer.setLength(0);
> 
> urlBuffer.append("/sports/welcome");
> 
> }
> 
> chain.doFilter(req,res);
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message