Using a Filter to serve a specific page?
Posted
by user246114
on Stack Overflow
See other posts from Stack Overflow
or by user246114
Published on 2010-05-23T20:39:22Z
Indexed on
2010/05/23
21:10 UTC
Read the original article
Hit count: 309
Hi,
I am using a class which implements Filter for my jsp stuff. It looks like this:
public class MyFilter implements Filter
{
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
request.getRequestDispatcher("mypage.jsp").forward(request, response);
}
}
So the target, "mypage.jsp", is just sitting in my top-level directory. The filter works fine if I'm entering urls like:
http://www.mysite.com/foo
http://www.mysite.com/boo
but if I enter a trailing slash, I'll get a 404:
http://www.mysite.com/foo/
http://www.mysite.com/boo/
HTTP ERROR: 404
/foo/mypage.jsp
RequestURI=/foo/mypage.jsp
it seems if I enter the trailing slash, then the filter thinks I want it to look for mypage.jsp in subfolder foo or boo, but I really always want it to just find it at:
http://www.mysite.com/mypage.jsp
how can I do that?
Thank you
© Stack Overflow or respective owner