• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session timeout

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have the following situation.

In my application, there are 4 to 5 beans in session scope. These beans
will be created at different periods of time.

The business rule is, if a bean is not accessed for more than a period of time
(say 10min), that bean should be reset to default values. This rule applies
to only a couple of beans...not all.....

Now, i feel i cannot set session timeout for this..bcos i fear i may loose all the beans.....

Is my understanding is correct???

Help pls.....TIA

Vijay




and
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Vijay,
Hope your business rules need to set session time out for each bean i.e, Bean based. But the "Session time out" we're speaking is application based. So as per m understandin you cannot do this.
 
Vijay Vaddem
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Shankar,

Is there any other work around for this kind of situation???

 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like you will need to use a Thread that wakes up after a certain no of seconds/minutes and checks if the bean has been accessed and takes the required action.

So, you can have a variable in the bean that records the time it is accessed, and when the thread wakes up it checks the value of that variable, if the difference from the current time is more than the 'timeout' value, it resets it.

But you might want to see if there is another way of enforcing that business requirements using some built-in session/request/application feature. Creating your own threads can get messy if you are not totally comfortable with multi-threading concepts, and if you do decide to use it, you will need to decide whether to run that a thread for the app or each session or each bean etc..
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vijay,

I have a theoritical solution. You can add a HttpSessionAttributeListener and in the "attributeAdded" method, check the name of the attribute added(In your case probably each bean) and when added put this time in session as a variable.

In each JSP of your page or in super class of that JSP (if you have one) include a small jsp file (include file) which checks for the time differences from the time each bean inserted in the session to the present request time(System.getTimeInMillis() I guess) and based on that you can do what ever you want.

Giri.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic