axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Daniels <gdani...@macromedia.com>
Subject RE: How to obtain reference to the ServletContext?
Date Mon, 18 Mar 2002 04:40:29 GMT
Glad you got things happening.  Sorry about the "context" typo, serves me right for coding
this late on a Sunday night. :)
 
--G

-----Original Message-----
From: Bryan Field-Elliot [mailto:bryan_lists@netmeme.org]
Sent: Sunday, March 17, 2002 11:40 PM
To: axis-dev@xml.apache.org
Subject: RE: How to obtain reference to the ServletContext?


That's the secret sauce, thanks! 

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 


Mime
View raw message