• 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

HttpSession. setMaxInactiveInterval versus session-timeout in DD

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm wondering if who has the higher priority?
For example if a webapp has a DD declared
, 15 being 15 mins and then a servlet sets the
, 5 being 5 seconds; which does the servlet container favors? the DD declaration or the method call?
 
Doyle Matt
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i'm answering my question. apparently the <session-timeout> is a "global" setting. but the session.setMaxInactiveInterval(int) are for specifics or "local" settings.

global meaning those sessions that didn't have their setMaxInactiveInterval set will use the one from the dd. but for those you went thru to the setMaxInactiveInterval will use the one that was set for that specific session object.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are correct,

DD declaration is global and applies to all sessions if not over written by using session.setMaxInactiveInterval(seconds) method.

setMaxInactiveInterval(seconds) method of HttpSession interface sets timeout for a particular session.

There is another difference between the two:
setMaxInactiveInterval() method:- -ve time(as parameter) indicates the session should never timeout
<session-timeout> 0 or -ve </session-timeout>:- 0 or -ve indicates the session should never timeout
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

Here I am trying to understand the real purpose of session configuration in Web.xml for session timeout.


<!-- Session Configuration -->
<session-config>
<session-timeout>60</session-timeout>
</session-config>

Now let me tell about my question..

my application is importing/uploading a .txt file and which is bound to take more than 1 hour Since there are millions of records to be imported.
But session gets timed out after 1 hour though my application is still importing that .txt file which is in progress.
As such application should not timeout as application is doing some task in background.

Thanks,
Vineet

 
Creator of Enthuware JWS+ V6
Posts: 3411
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
Hi,

I am not sure what you are asking because the answer in my opinion is given in this thread, but here the paragraph about the element of the Servlet 3.0 spec:

<session-config>
The session-config defines the session parameters for this Web application. The sub-element session-timeout defines the default session time out interval for all sessions created in this Web application. The specified time out must be expressed in a whole number of minutes. If the time out is 0 or less, the container ensures the default behavior of sessions is never to time out. If this element is not specified, the container must set its default time out period.



Regards,
Frits
 
Greenhorn
Posts: 6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
vineet I think I see your confusion: session-timeout is meant to describe the maximum period of inactivity after which the session is invalidated, AND NOT the whole duration allowed for a session.

for example sission-timeout could be 10 minutes, but if you keep sending requests you can stay there the day long.
reply
    Bookmark Topic Watch Topic
  • New Topic