I have a javax.servlet.Filter class that I would like to redirect urls. The problem is that when I call
httpResponse.sendRedirect("http://myurl/login.jsp")
return;
it doesn't redirect to there. I can see from the firebug network console that the request matches the correct url, but the page doesn't change and the current address bar url remains unchanged.
The request looks valid.
Request URL:http://myurl/login.jsp
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Host:localhost:7001
Referer:http://myurl/index.jsp
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19
X-Requested-With:XMLHttpRequest
Response Headersview source
Content-Language:en-US
Content-Length:764
Content-Type:text/html; charset=ISO-8859-1
Date:Fri, 27 Apr 2012 16:49:55 GMT
X-Powered-By:Servlet/3.0 JSP/2.2
The response contains the contents of login.jsp
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<body>
...
</body>
</html>
I have tried using
request.getRequestDispatcher("/login.jsp").forward(request, response);
and that just doesn't work, as I see in Firebug it requests the url that I am currently on.