axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Field-Elliot <bryan_li...@netmeme.org>
Subject RE: How to obtain reference to the ServletContext?
Date Mon, 18 Mar 2002 04:39:36 GMT
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