Because of some reasons I have a spring application which has two client applications written in extjs. One only contains the login page and the other the application logic. In Spring I include them into two jsp pages which I’m using in the controller.
The login and the redirect to the application page works fine. But if I logout the logout is done successful but I keep staying on the application page instead of being redirected to the login page.
security config:
<security:logout logout-url="/main/logoutpage.html" delete-cookies="JSESSIONID" invalidate-session="true" logout-success-url="/test/logout.html"/>
Controller:
@RequestMapping(value="/test/logout.html",method=RequestMethod.GET)
public ModelAndView testLogout(@RequestParam(required=false)Integer error, HttpServletRequest request, HttpServletResponse response){
return new ModelAndView("login");
}
“login” is the name of the view which contains the login application. In browser debugging I can see following two communcation:
Request URL:http://xx:8080/xx/xx/logoutpage.html?_dc=1358246248972
Request Method:GET
Status Code:302 Moved Temporarily
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Cookie:JSESSIONID=6E22E42CC6835C8A6DFF2535907DEF17
Host:xx:8080
Referer:http://xx:8080/xx/xx/Home.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
X-Requested-With:XMLHttpRequest
Query String Parametersview URL encoded
_dc:1358246248972
Response Headersview source
Content-Length:0
Date:Tue, 15 Jan 2013 10:37:33 GMT
Location:http://xx:8080/xx/xx/login.html
Server:Apache-Coyote/1.1
Set-Cookie:JSESSIONID=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/xx
Request URL:http://xx:8080/xx/xx/login.html
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:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Cookie:JSESSIONID=6E22E42CC6835C8A6DFF2535907DEF17
Host:xx:8080
Referer:http://xx:8080/xx/xx/Home.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
X-Requested-With:XMLHttpRequest
Response Headersview source
Content-Language:de-DE
Content-Length:417
Content-Type:text/html;charset=ISO-8859-1
Date:Tue, 15 Jan 2013 10:37:33 GMT
Server:Apache-Coyote/1.1
Set-Cookie:JSESSIONID=532EBEED737BD4172E290F0D10085ED5; Path=/xx/; HttpOnly
The second response also contains the login page:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<script src="http://extjs.cachefly.net/ext-4.1.1-gpl/ext-all.js"></script>
<link rel="stylesheet" href="http://extjs.cachefly.net/ext-4.1.1-gpl/resources/css/ext-all.css">
<script type="text/javascript" src="/xx/main/app/app.js"></script>
</head>
<body></body>
</html>
Somebody has an idea why the login page is not shown?
Thanks
Instead of custom JavaScript handler for logout control just use a normal link:
Logout controller uses HTTP redirect to show login page. In a case of AJAX call redirect does not work like you want. Look into XmlHttpResponse of your AJAX call. You will find the logout page there.