• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

How to test HttpSessionListener

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created below Listener to track how many sessions are created. However, If I open number of browsers the below sessionCreated() method is executed only once. I thought every brower request treated as a seperate session. If it is true, below sessionCreated() method will call for every newly created session(In this case for every new browser request). Please let me know whether my understanding is right or wrong.

And how to test the below HttpSessionListener.




Thanks,
Siva
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe because your browser is sharing the session.

Try with different browsers, or search in google how to do your browser to create a new session per tab.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If each request from a browser is treated as a new session, then what's the use of session? Try to open your page from different browsers (like one from Firefox, one from Chrome and one from IE). You'll get different session for each browser...
 
jami siva
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Garg.

I tried with different browsers, one with IE and another with Mozilla, still I am getting only one session.
Apart from this, what should I do.

Thanks,
Siva
 
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I tried with different browsers, one with IE and another with Mozilla, still I am getting only one session.
Apart from this, what should I do.


How does your web.xml look like?

What URL do you use? Do you use tomcat, if so what version?

Regards,
Frits
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the code in the Servlet that allows you to get the count of activeSessions. I suspect you are stuffing this in the session.setAttribute("activeSessionCOunter", activeSessions);

However, you will need another static method that returns this session counter


Now you can try this code in multiple browsers ...Chrome, IE, Saffari, or from multiple computers

I figure you will see number increase as sessions join!

jami siva wrote:I created below Listener to track how many sessions are created. However, If I open number of browsers the below sessionCreated() method is executed only once. I thought every brower request treated as a seperate session. If it is true, below sessionCreated() method will call for every newly created session(In this case for every new browser request). Please let me know whether my understanding is right or wrong.

And how to test the below HttpSessionListener.




Thanks,
Siva

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. Sessions are referenced using cookies, and cookies are set per-client, not per-window.
Same session/session-timeout mechanism will be referred if client is sending requests from various different browser.
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic