You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Chris Malley <cm...@pixelzoom.com> on 2002/01/30 22:20:12 UTC

access to ServletContext

I know that I can get my SOAP serlvet's ServletContext by adding
SOAPContext as an arg to my Java methods.  Eg:
 
   void mymethod( SOAPContext context )
   {  HttpServletRequest request =
(HttpServletRequest)SOAPContext.getProperty(Constants.BAG_HTTPSERVLETREQUEST);
      // etc.
   }

Is there any other way to get SOAP's ServletContext?  There are things
that 
I need to configure on a per-class basic (eg, logging) and having to 
access the SOAPContext in each method is (a) ugly, (b) wasteful, and
(c) Apache-specific.  

Here's one example of why I'm asking:

I've configured a logfile for SOAP by adding a Context and Logger
to $CATALINA_HOME/conf/server.xml.    Now I'd like all of my 
SOAP-hosted classes to write to that log file.   This log file is
available via the SOAP servlet's ServletContext.log.  I'd like to
set the log file once in the class constructor, not in every method,
like this:

public class MyClass {
  ServletContext context = null;
  MyClass() {
    context = // how do I do this?
  }
  void method1() { context.log("method1 called"); }
}

Thanks,

-Chris