Hi Bryan!
 
If you know that your service is definitely using HTTP, you can use the following code to get the ServletContext:
 
MessageContext context = MessageContext.getCurrentContext();
HttpServlet servlet = (HttpServlet)context.getProperty(HTTPConstants.MC_HTTP_SERVLET);
ServletContext context = servlet.getServletContext();
 
In other words, the AxisServlet will automatically set a variety of transport-specific properties in the MessageContext that carries each request/response.  Any component (service object, handler, etc) which knows to ask for these will be able to obtain them as above.
 
Hope this helps,
--Glen
-----Original Message-----
From: Bryan Field-Elliot [mailto:[EMAIL PROTECTED]]
Sent: Saturday, March 16, 2002 11:57 AM
To: [EMAIL PROTECTED]
Subject: How to obtain reference to the ServletContext?

I'm new to Axis... In developing services to run under Axis (server-side), is there a way to obtain a reference to the Axis servlet's ServletContext?

I intend to deploy my Axis-based SOAP services in the same web context (.war) as an existing web-based application. I want both applications to share the same Servlet context, where I have a set of shared attributes for things like connection pools, cached database data, configuration parameters (taken from web.xml), etc.

Any pointers would be appreciated.

Thank you,
Bryan

Reply via email to