Better to change my question:

When a session associated with a client is created?


Hi,
I have a filter (for /*) in which I'm caching something in the
session. Here is a piece of code:

public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) {
        HttpServletRequest req = (HttpServletRequest) request;
        HttpSession session = req.getSession(false);
        if (session == null) {
                System.out.println("Create a new session: " + new 
java.util.Date());
                session = req.getSession();
        }
        // cache something
}

The first time I make a request, since req.getSession(false) returns
null, a session is created by a call to req.getSession() manually.
The second time I make a request to the server, req.getSession(false)
returns null and so a session is created again.
In all other request (third, ...) the last created session (second) is returned!

My question is why session is created two times?

Thanks in advance.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to