Q: How can i get access to the <noWiki>ServletContext</noWiki> from my code?

A: There are at least two ways. One is Axis Specific, and one is specified by the JAX-RPC standard.

This is the axis specific way.

HttpServlet srv = (HttpServlet) MessageContext.getCurrentContext().getProperty(HTTPConstants.MC_HTTP_SERVLET);
ServletContext context = srv.getServletContext();

This is the JAX-RPC way. Since Axis is an implementaiton of JAX-RPC axis supports this as well. It's more verbose, but then again portable almost always means verbose.

...
import javax.servlet.ServletContext;
import javax.xml.rpc.server.ServiceLifecycle;
import javax.xml.rpc.server.ServletEndpointContext;
...

public class &lt;service&gt;BindingImpl implements &lt;service&gt;, ServiceLifecycle {

...
{{{    ServletContext servletContext; 

... {{{ public void destroy() { ... }

...

AxisProjectPages/ServletContext (last edited 2009-09-20 23:31:23 by localhost)