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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
