Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How HttpSessionActivationListener works?  RSS feed

 
Dhiren Lodhia
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I m preparing for SCWCD EE5(310-083) and while preparing came across sessions management.
i also understood listeners of all types.
including 'HttpSessionActivationListener '

i did all practicals regarding all other listeners and its all working great

but HttpSessionActivationListener is where i am not really clear.

first of all it defines two metods

public void sessionWillPassivate(HttpSessionEvent e) &
public void sessionDidActivate(HttpSessionEvent e)

now from whatever i read it stats that above both methods will get called by container when a session moves from one JVM TO ANOTHER JVM.

i guess it means to different web containers (2 tomcat severs running on localhost on different port)

So i tried testing this practically on my system with two different tomcat running (tomcat5.5 & tomcat6.0)
i created a Session through servlet and then once session is created i try to transfer the request to the other JVM(tomcat) hoping that the session will also get transferred but it does not get moved to second JVM.

following is code what i thought will work :
Simple HTML form

web.xml

Implementing Class

First Servlet

Second Servle


now i had deployed this entire web application on two server on local machine
Tomcat 6 :8085
Tomcat 5 :8080

and i was hoping that after creating session on Tomcat 6 :8085 when i will move to Tomcat 5 :8080 by link (i also did encoding for that) my session should also move from JVM1 Tomcat6 to JVM2 Tomcat5.

it didnt work on did not get my old session on other server.

is this a correct way to test this concept??
am i doing something stupid with all of this??
i was just trying to test it ??

please help . sorry for making you all read so much.......
 
ryan sukale
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dhiren
I dont think this is the right way to test this concept.

In my opinion, sessions are passivated/activated only when the server decides that it needs to migrate the session. This is a scenario in distributed applications. So, I dont think that you can actually test this manually unless you are running a distributed application.

Of course, i might be wrong. If so, do, let me know, where i am going wrong. Thanks.
 
Sunil Vasudevan
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ryan is correct. It needs to be in a cluster for session to migrate.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!