This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HttpSessionListener  custom methodsin HFSJ page 259 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HttpSessionListener  custom methodsin HFSJ page 259" Watch "HttpSessionListener  custom methodsin HFSJ page 259" New topic
Author

HttpSessionListener custom methodsin HFSJ page 259

Ner min
Ranch Hand

Joined: Sep 14, 2005
Posts: 76

i wondering are all this SessionListeners bound to som scope by container?
What i mean is i know i can call the method from the calling code by:

but i thought,due to the fact that container is able to call the
sessionCreated and sessionDestroyed he allready must have instantated an object of type HSessL. So my questions is do we have to instatiete it again via new HSessL() (whcih would be stupid ) or thoes the container makes it availabele so we r able to do something like:
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
You need to have getAccCount() method as static, otherwise u cannot get that number.
When you have static method, with just class name, you can get the number of active users.


Rizwan
SCJA, SCJP, SCWCD, SCBCD, SCDJWS.
Ner min
Ranch Hand

Joined: Sep 14, 2005
Posts: 76
hi Rizwan, yes that is the onother way
but as i sed, that container is able to call the
sessionCreated and sessionDestroyed (and they r not STATIC) so he allready must have INSTANTIATED an object of type HSessL SOMEWHERE. I just thought the Sun-dudes make it also availabel to as mortall-coders.
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215
Hi,

the container does create the HSessL object but I don't believe that the container makes it available anywhere. You can do this in the sessionCreated method though with something like the following

Note that I have not tested any of this code, so it might have some errors in it, but you should have enough to get the idea.



and then get the object elsewhere with something like


Mat
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpSessionListener custom methodsin HFSJ page 259