Be very careful how you put those parameters in the web.xml file. Here is a working
sample -
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<display-name>Apache-Axis</display-name>
<!-- initialization parameters for all web services/web apps deployed in this
context. -->
<!-- the demo .fo file for the FOP Web Service-->
<context-param>
<param-name>fop_demoFoFileName</param-name>
<param-value>demo.fo</param-value>
<description>foo desc</description>
</context-param>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AxisServlet
</servlet-class>
A common mistake that people make is placing the init parameters under the AxisServlet
declaration under <init-param> tags.
Thanks
Srinivas
-----Original Message-----
From: Ben Souther [mailto:[EMAIL PROTECTED]
Sent: Monday, December 15, 2003 5:54 AM
To: [EMAIL PROTECTED]
Subject: Re: Environment variables
You could implement ServiceLifecycle and store the value as an init param in
your web.xml file.
import javax.xml.namespace.QName;
import javax.xml.rpc.server.ServletEndpointContext;
import javax.xml.rpc.server.ServiceLifecycle;
import javax.xml.rpc.ServiceException;
import javax.servlet.ServletContext;
public class myService implements ServiceLifecycle{
private String location;
/**
* Required by interface, ServiceLifecycle.
*/
public void init(Object context) throws ServiceException {
ServletEndpointContext ctx = (ServletEndpointContext)context;
ServletContext servletContext = ctx.getServletContext();
this.location = (String)servletContext.getInitParameter("location");
}
/**
* Required by interface ServiceLifecycle.
*/
public void destroy(){}
}
This is working for me with Tomat/Apache on both Windows and Linux.
On Monday 15 December 2003 03:59 am, Guillermo Arias del Rio wrote:
> hi,
>
> I want to set a parameter for my server (where a configuration file
> is). I haven't found any way to provide a parameter to the servlet
> constructor via wsdd. I'm trying to achieve this with an environment
> variable, but it seems not to work (and it is system-dependent)... Is
> there any way to tell Axis to run the constructor of my servlet with a
> parameter?
>
> I'm developing in Linux with Axis-Tomcat. The code I'm using to get
> the environment is:
>
> private static java.util.Properties getEnvironment() throws IOException {
> java.util.Properties env = new java.util.Properties();
> env.load(Runtime.getRuntime().exec("env").getInputStream());
> return env;
> }
>
> Thanks
--
Ben Souther
F.W. Davison & Company, Inc.