• 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
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

I need handle all user sessions in struts2 like tomcat manager application

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need handle all user sessions in struts2 like tomcat manager application
 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean 'handle'? Also, what have you tried and where are you stuck?
 
vikas byn
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to invalidate some sessions if certain situation occurred.
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can call SessionMap.invalidate http://struts.apache.org/release/2.0.x/struts2-core/apidocs/org/apache/struts2/dispatcher/SessionMap.html#invalidate()
 
vikas byn
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

E Armitage wrote:You can call SessionMap.invalidate http://struts.apache.org/release/2.0.x/struts2-core/apidocs/org/apache/struts2/dispatcher/SessionMap.html#invalidate()



It will invalidate only current session not others.
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you can create an HTTPSessionListener and add all started sessions to a collection. You can then iterate all of them to invalidate them when you want to.
 
vikas byn
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

E Armitage wrote:Then you can create an HTTPSessionListener and add all started sessions to a collection. You can then iterate all of them to invalidate them when you want to.



it may cause memory leaks. it can store that session in which user just hit page not logged in and keeps its reference for always.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Obviously, you would also implement sessionDestroyed to remove sessions from your list when they expire.

it can store that session in which user just hit page not logged in


Do you really need to create a session for a user that is not logged in? (Not that it has anything to do with the problem at hand.)
 
vikas byn
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking into code to check when session created. Actually class used SessionAware interface when User logged in.

I am just thinking If user logged in and keep it to expire then we unfortunately store it also.

Is there is any Listener that will listen event of expire session?
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vikas byn wrote:I am looking into code to check when session created. Actually class used SessionAware interface when User logged in.

I am just thinking If user logged in and keep it to expire then we unfortunately store it also.

Is there is any Listener that will listen event of expire session?



The HtttpSessionListener does that.

 
That feels good. Thanks. Here's a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic