Purushotham Honey

Greenhorn
+ Follow
since Jul 21, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Purushotham Honey

Hello,
In my application, i need to perform some DB operations before session invalidates. How can i achieve this during the session timeout? Where should i write the code to perform DB operations?
12 years ago
I mean i require the jsp to maintain te already existing session instead of creating a new one. I have given the value true for the session attribute in page directive.
<%@page session="true" ......%>

I tried of URL rewriting, then also it is creating new sessions. How can i configure so that the jsp page will use already existing session?
12 years ago
Hi,
My requirement is to have only one session that too created after an user has logged in. But the issue is a new session is created when ever a resource is mapped through struts-config.xml. How can i prevent creating multiple session for each forward.

Note: I am using struts 1.3 for my application

Thanks in advance
12 years ago
Ya but the code is written in the action class for the login page. My intention is to have a new session created (not to use the previous session) when a user login. Is the code relevant for my requirement?
12 years ago
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
12 years ago

I want my web application to contain only one session created at login. But my server is creating a separate session for every request to a jsp page. How can i configure to have only one session in my application?
12 years ago