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?

Recommended Answers

All 3 Replies

I don't really have experience with this, but here is some info I found that may or may not be helpful.

This article suggests that compatibility mode creates a new session. And that one should "..set match user agent to FALSE".

cgeier,

I checked out the articles you mentioned but they didn't help much. Match useragent is part of the configuration of Codeigniter which is in PHP. My website runs on Tomcat and is in Java. The other articles couldn't help solve my problem neither. But thank you for the responses!

Your input is appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.