I am getting a very mysterious bug when I run my java website in Browser Mode: IE9 Compatibility View - the sessions stop working and I have no idea why. I don't think there is a tag or any code that I can include in my website that can force the client browser not to run in Compatibility View. I am using this tag to force the browser to pick the latest Document Mode though:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
I am using this code for setting the session in my LoginController.java:
import javax.servlet.http.*;
HttpSession session = request.getSession(true);
session.setAttribute("userObj", curr_user);
and this code for getting the session object in my .jsp pages:
HttpSession sess = request.getSession(false);
if(!(sess.getAttribute("userObj") == null)) {
User user = (User) sess.getAttribute("userObj");
username = user.getUsername();
role = user.getRole();
}
This works perfectlly fine in IE 9, IE 10, IE 11, Chrome, FF, etc. But when it comes to IE 9 Compatibility View this session is empty in the .jsp pages. As irony would have it, most of my users currently run exactly IE 9 Compatibility View for God knows what reason and they are not happy. I am not happy. Basically this little bug renders the whole site totally useless for them. Can anyone offer me some help in figuring this out, please?