I am working on a web application which uses STRUTS. All the client requests are directed to loginaction class.
Any resource in the application, is accessed thru the action class.
Overview: In the action class, i am checking if there is any session associated with the new user using
session = request.getSession(false);
if (session != null) {
if (session.isNew()) {
logger.info("New Session Created [" + session.getId() + "]");
} else {
logger.info("Session EXIST'S ["+ session.getId()
+ "], Retreiving user from session");
}
According to the Servlets 2.2 API:
public HttpSession getSession(boolean create)
Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.
If create is false and the request has no valid HttpSession, this method returns null.
if (session.isNew()) ,
this if statement should return false and be skipped,
as session = request.getSession(false);
wont create a new session. When i parse the logs, I see the log statement, "New Session Created ". Which makes me wonder, that a new session is being created
Problem: When i debug, i see that container is creating a new session if the session doesnt exist. According to API mentioned above, it should not create a new session.
It should return null.
Did anyone had a similar issue? While researching i found this article that using struts, the container creates a default session.
I found this article:
http://www.theserverside.com/discussions/thread.tss?thread_id=21643
Environment: IDE:WSAD5.1, Appserver:Websphere, Browser:IE 6.0, Struts, JSP, JSTL