Sure
The following the code written in my action servlet (I have used
struts 1.3)
HttpSession sess = request.getSession (true);
if (sess.isNew() == false) {
sess.invalidate();
sess = request.getSession(true);
}
I confirmed that multiple sessions has created by using a HttpSessionListener
The following is the sample code that the console generated
********About to create a session(LoginAction.execute.if)******** //generated by sys.out
--------Session Destroyed--------Remaining : 0 //generated by sys.out
--------Session Created--------Active : 1 //generated by sys.out
29486 [http-8080-1] DEBUG org.hibernate.event.def.DefaultSaveOrUpdateEventListener - saving transient instance
29486 [http-8080-1] DEBUG org.hibernate.id.IncrementGenerator - fetching initial value: select max(sid) from TESTSCHEMA.sessiondb
29486 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
29486 [http-8080-1] DEBUG org.hibernate.SQL - select max(sid) from TESTSCHEMA.sessiondb
Hibernate: select max(sid) from TESTSCHEMA.sessiondb
29486 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
29488 [http-8080-1] DEBUG org.hibernate.id.IncrementGenerator - first free id: 58
29488 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
29488 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
29488 [http-8080-1] DEBUG org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 58, using strategy: org.hibernate.id.IncrementGenerator
29488 [http-8080-1] DEBUG org.hibernate.event.def.AbstractSaveEventListener - saving [com.vunya.hibernate.beans.SessionDB#58]
29495 [http-8080-1] DEBUG org.hibernate.transaction.JDBCTransaction - commit
29495 [http-8080-1] DEBUG org.hibernate.impl.SessionImpl - automatically flushing session
29495 [http-8080-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - flushing session
29496 [http-8080-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades
29496 [http-8080-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
29496 [http-8080-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
29498 [http-8080-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections
29498 [http-8080-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
29499 [http-8080-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 insertions, 0 updates, 0 deletions to 2 objects
29499 [http-8080-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
29499 [http-8080-1] DEBUG org.hibernate.pretty.Printer - listing entities:
29499 [http-8080-1] DEBUG org.hibernate.pretty.Printer - com.vunya.hibernate.beans.SessionDB{sid=58, logintime=2011-07-21 23:48:27, sessionId=ABF61476D191C40B77B8AF570ABB74EA, userName=agu1, password=agp1}
29499 [http-8080-1] DEBUG org.hibernate.pretty.Printer - com.vunya.hibernate.beans.LoginCheck{username=agu1, userid=1, type=1, password=agp1}
29499 [http-8080-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush
29499 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - registering flush begin
29499 [http-8080-1] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Inserting entity: [com.vunya.hibernate.beans.SessionDB#58]
29504 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
29504 [http-8080-1] DEBUG org.hibernate.SQL - insert into TESTSCHEMA.sessiondb (sessionid, username, password, logintime, sid) values (?, ?, ?, ?, ?)
Hibernate: insert into TESTSCHEMA.sessiondb (sessionid, username, password, logintime, sid) values (?, ?, ?, ?, ?)
29504 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
29505 [http-8080-1] DEBUG org.hibernate.persister.entity.AbstractEntityPersister - Dehydrating entity: [com.vunya.hibernate.beans.SessionDB#58]
29505 [http-8080-1] DEBUG org.hibernate.type.StringType - binding 'ABF61476D191C40B77B8AF570ABB74EA' to parameter: 1
29505 [http-8080-1] DEBUG org.hibernate.type.StringType - binding 'agu1' to parameter: 2
29505 [http-8080-1] DEBUG org.hibernate.type.StringType - binding 'agp1' to parameter: 3
29505 [http-8080-1] DEBUG org.hibernate.type.TimestampType - binding '2011-07-21 23:48:27' to parameter: 4
29506 [http-8080-1] DEBUG org.hibernate.type.IntegerType - binding '58' to parameter: 5
29509 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
29509 [http-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
29509 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - registering flush end
29510 [http-8080-1] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - post flush
29510 [http-8080-1] DEBUG org.hibernate.jdbc.JDBCContext - before transaction completion
29510 [http-8080-1] DEBUG org.hibernate.impl.SessionImpl - before transaction completion
29512 [http-8080-1] DEBUG org.hibernate.transaction.JDBCTransaction - committed
JDBC Connection
29512 [http-8080-1] DEBUG org.hibernate.jdbc.JDBCContext - after transaction completion
29512 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
29512 [http-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
29513 [http-8080-1] DEBUG org.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
29513 [http-8080-1] DEBUG org.hibernate.impl.SessionImpl - after transaction completion
29513 [http-8080-1] INFO LOG - Logged in as Agent
29513 [http-8080-1] INFO LOG - User name : agu1
29513 [http-8080-1] INFO LOG - Password : agp1
29513 [http-8080-1] INFO LOG - Session ID : ABF61476D191C40B77B8AF570ABB74EA
29513 [http-8080-1] DEBUG org.apache.struts.tiles.TilesRequestProcessor - processForwardConfig(/Agent/dashboard.jsp, false)
29514 [http-8080-1] DEBUG org.apache.struts.tiles.TilesRequestProcessor - '/Agent/dashboard.jsp' - processed as uri
29514 [http-8080-1] DEBUG org.apache.struts.action.RequestProcessor - processForwardConfig(ForwardConfig[name=success1,path=/Agent/dashboard.jsp,redirect=true,contextRelative=false,module=null])
29528 [http-8080-2] DEBUG org.apache.struts.util.PropertyMessageResources - Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
--------Session Created--------Active : 2
--------Session Created--------Active : 3
--------Session Created--------Active : 4
.........
Please can you help in resolving my problem