users@glassfish.java.net

Re: Session-ID Problem

From: <glassfish_at_javadesktop.org>
Date: Thu, 22 Oct 2009 02:48:03 PDT

Hello Jan,

thanks for your answer.

I can follow that they changed the concept with servlet 3.0 and I try out your example.

But I still get the same (wrong) behavior.

I add a ServletContextListener:

public class MyServletContextListener implements ServletContextListener {
    private static Logger log = Logger.getLogger("MyServletContextListener");
    public void contextInitialized(ServletContextEvent e) {
        log.info("contextInitialized");
        e.getServletContext().setSessionTrackingModes(EnumSet.of(SessionTrackingMode.URL));
    }
    public void contextDestroyed(ServletContextEvent e) { }
}

and add the listener to the web.xml:

<listener>
   <listener-class>MyServletContextListener</listener-class>
</listener>

The log entry: contextInitialized appears, but the session still changes with every reload.

I also try to do it declaratively and add in the sun-web.xml the following lines:

<session-config>
    <session-properties>
        <property name="enableCookies" value="false" />
    </session-properties>
</session-config>

Every time I call the page with an existing session-id glassfish creates a new one.
What is wrong in this example?

Thanks Holger
[Message sent by forum member 'hbrade' (holger_at_hbrade.com)]

http://forums.java.net/jive/thread.jspa?messageID=368931