Been buggin' me.
So, I'm using JSP and there are these methods (simplistic example) inside my implemented Filter and my extended HttpServlet, respectively:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
((HttpServletResponse) response).sendRedirect(((HttpServletRequest) request).getContextPath() + "/foo");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.sendRedirect(request.getContextPath() + "/foo");
}
At localhost:8080/app, both Filter and HttpServlet correctly redirect me to localhost:8080/app/foo.
But at www.mysite.com/app, which hides a tomcatserver:8080/app under Apache's proxy as follows,
RedirectPermanent /app /app/
ProxyPass /app/ http://tomcatserver:8080/app/
ProxyPassReverse /app/ http://tomcatserver:8080/app/
the Filter redirects me ok to www.mysite.com/app/foo, while the HttpServlet either:
- (from same domain) reveals the Tomcat's server address, redirecting me to
tomcatserver:8080/app/fooor - (from outside the domain) just gets stuck loading.
So... what's causing this?
P.S.: I know that removing the request.getContextPath() and the "/" part from the HttpServlet solves the problem, I'm not asking that.