File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes BEA/Weblogic and the fly likes Access HttpSession from static methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Access HttpSession from static methods" Watch "Access HttpSession from static methods" New topic

Access HttpSession from static methods

chris macneel

Joined: Dec 18, 2002
Posts: 1
I support a Web application written on the Weblogic 6.1 platform. All logging is issued via a log4j wrapper class called Logger. This class has several static methods (debug, info, warning, etc.) that call into log4j Category methods.
As these methods are static, they're being called from many different sources (servlets, filters, beans) without instantiating the Logger class.
I would like to pull specific user information from the HttpSession (home-grown authentication using public name) and append this to the logged message, but the Logger class static methods do not have direct access to the HttpSession.
Also, at any one point in time, I don't know whether these static methods are participating in a session.
My question: Is there an appropriate way to create a stateful session bean, populate with user info and later retrieve the bean from Logger to pull the info? Where's the best place to instantiate the session bean?
I agree. Here's the link:
subject: Access HttpSession from static methods
It's not a secret anymore!