axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "I-Sampige, Srinivas" <>
Subject RE: Environment variables
Date Mon, 15 Dec 2003 20:59:09 GMT
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"


  <!-- initialization parameters for all web services/web apps deployed in this context.

  <!-- the demo .fo file for the FOP Web Service-->
    <description>foo desc</description>

    <display-name>Apache-Axis Servlet</display-name>

A common mistake that people make is placing the init parameters under the AxisServlet declaration
under <init-param> tags. 


-----Original Message-----
From: Ben Souther [] 
Sent: Monday, December 15, 2003 5:54 AM
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.

View raw message