File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes session doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "session doubt" Watch "session doubt" New topic
Author

session doubt

sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

<session-config>
<session-timeout>0</session-timeout>
</session-config>

and

session.setMaxinActiveInterval(0);

both are same or different?
setting 0 thru DD will cause session never to expire
setting thru program will cause session to expire immidiately.is this correct?


Sudheer
SCWCD, SCJP 5
raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169
Hi,

Yes, both are same. Whatever you declare in DD will be returned by the getMaxInactiveInterval method. both DD and setMaxInactiverInterval will behave in same way as long as the value is same if different then Programmatic values will always override DD values.

Thanks
sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

if both are same then why dont their behavour is same

when we set 0 thru DD ,session never expires
when v set 0 thru program it expires immidiately.
Gaurav Gambhir
Ranch Hand

Joined: Mar 04, 2006
Posts: 254
The values specified in Deployment Descriptor for <session-timeout> is always in minutes

and setMaxInactiveInterval() method accepts value in seconds.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by sudheer kiran:

setting 0 thru DD will cause session never to expire
setting thru program will cause session to expire immidiately.is this correct?


correct

Originally posted by raja ram:
Yes, both are same.


No.
Gaurav Gambhir
Ranch Hand

Joined: Mar 04, 2006
Posts: 254
Yes seetharaman is right ,

Now programatically, session will never expire if negative value is given to setMaxInactiveInterval().
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
The difference was introduced to add spice for certification exams like scwcd .


SCJP, SCWCD, SCBCD
Sandeep Bhandari
Ranch Hand

Joined: Apr 16, 2004
Posts: 201
Originally posted by Gaurav Gambhir:
The values specified in Deployment Descriptor for <session-timeout> is always in minutes

and setMaxInactiveInterval() method accepts value in seconds.


I would remember it like:
DD is for long term perspective and if you need longer session timeout interval (i.e. minutes) go for it.

But if your session is short lived, you can set it progrmatically (i.e. seconds)


SCJP 96% | SCWCD 90%| SCJP mock exams | My SCJP blog
Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
You're using programmatic values? Shame on you. Never! Use declarative, and consider yourself lucky.


Anton Golovin (anton.golovin@gmail.com) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session doubt