Glad
you got things happening. Sorry about the "context" typo, serves me right
for coding this late on a Sunday night. :)
--G
-----Original Message-----That's the secret sauce, thanks!
From: Bryan Field-Elliot [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 17, 2002 11:40 PM
To: [EMAIL PROTECTED]
Subject: RE: How to obtain reference to the ServletContext?
It took me a little bit to figure out which imports to make based upon your types (had to dig through the JavaDocs). Also you have the variable "context" defined twice, I obviously had to change that. But this works like a charm so thank you!
Bryan
On Sun, 2002-03-17 at 21:23, Glen Daniels wrote: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