My login ajax call is like this
$.get("LoginServlet", {'agileid': id, 'passwd': passwd, 'remember': 'yes' }, function(data) {
var results = JSON.parse(data);
if ( results.status == "failed") alert(data);
else window.location.href = 'Main.jsp';
});
My LoginServlet will set a session attribute special object which cannot be saved on the client side.
In Main.jsp, will determine existence of the session object and perform the necessary actions.
<%@page import="agile.px.myagiledashboard.listeners.SessionResourcesObject"%>
<%@ page contentType="text/html;charset=UTF-8" session="false" %>
<!DOCTYPE html>
<%
HttpSession hSession = request.getSession();
System.out.println("Main.jsp: " + hSession.getId()); //This is to make sure the session is the same as in LoginServlet request
SessionResourcesObject SRO = (SessionResourcesObject) hSession.getAttribute("SRO");
String userName = "";
if ( SRO != null) {
try {
userName = SRO.getCUser();
System.out.println("main.jsp: " + userName);
} catch (Exception e) {
}
}
%>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
....
The code works with Chrome but when run in IE11 (in compatibility mode - company IT policy - can't change), the session object is always null after redirected to the jsp page.
Anyone one has the same problem? Or can anyone point out the problem(s) in my code and to fix this?
Thanks,
Alex
Strange enough: Using location.href solved the problem. Chrome does not behave differently , but in IE11 location.href will not create a new session but window.location.href will.