You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Akacem Mohammed <Mo...@arbeitsamt.de> on 2002/12/06 16:24:28 UTC

AW: Initialization Parameters

I tried the following , but it didn't work may be I am missing something.



my code: ( this code snippet is not part of init(java.lang.Object context) of the ServletLifeCyle interface  but part of a normal configuration class)

 ServletEndpointContextImpl endpoint= new ServletEndpointContextImpl();
 ServletContext cont= endpoint.getServletContext();
 System.out.println("Config from web.xml  ="+cont.getInitParameter("Config"));// I get null

below is my web.xml file, myay be I put my parameter in the wrong place.

thanks for any hint

Mohammed



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <servlet>
    <servlet-name>AdminServlet</servlet-name>
    <display-name>Axis Admin Servlet</display-name>
    <servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>AxisServlet</servlet-name>
    <display-name>Apache-Axis Servlet</display-name>
    <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
    <init-param>
      <param-name>Config</param-name> <!-- this is the parameter I am trying to read  but I get null 								instead of path1-->
      <param-value>path1</param-value>
    </init-param>
  </servlet>
  <servlet>
    <servlet-name>debugjsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
      <param-name>jspCompilerPlugin</param-name>
      <param-value>com.borland.jbuilder.webserverglue.tomcat.jsp.JasperSunJavaCompiler</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>debugjsp</servlet-name>
    <url-pattern>*.jsp</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>*.jws</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>AdminServlet</servlet-name>
    <url-pattern>/servlet/AdminServlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/servlet/AxisServlet</url-pattern>
  </servlet-mapping>
</web-app>



-----Ursprüngliche Nachricht-----
Von: Ben Souther [mailto:bsouther@fwdco.com]
Gesendet: Montag, 18. November 2002 09:44
An: axis-user@xml.apache.org
Betreff: Re: Initialization Parameters


My code is a little different. All I'm doing is getting init params from the 
web.xml.
Here is my code:
getContext().getInitParameter("init-param")

I don't know if that's all you were trying to do before.






On Friday 15 November 2002 05:00 pm, Ben Souther wrote:
> It is running in one of my apps.
> I'm using Axis 1.0 with Tomcat 4.1.12
>
> On Friday 15 November 2002 04:43 pm, Vidyanand Murunikkara wrote:
> > Hi Ben
> >
> > When you said "it works well" did u mean u tried it out and it worked
> > fine ? I was under the impression this feature doesn't exist. I checked
> > the code and it doesn't seem to be in there. And Steve Loughran from the
> > Axis commiter list also said that this feature is not supported.
> > http://marc.theaimsgroup.com/?l=axis-user&m=103679570405098&w=2.
> >
> > Vidyanand.
> >
> >
> >
> > -----Original Message-----
> > From: Ben Souther [mailto:bsouther@fwdco.com]
> > Sent: Friday, November 15, 2002 6:16 AM
> > To: axis-user@xml.apache.org
> > Subject: Re: Initialization Parameters
> >
> >
> > While digging through the archives, I found this and it works well.
> > Thanks Eric Jung.
> >
> >
> >
> >
> > List:     axis-user
> > Subject:  RE: Beginner's question
> > From:     "Jung, Eric (Contractor)" <ej...@russellmellon.com>
> > Date:     2002-08-16 16:04:47
> > [Download message RAW]
> >
> > How about this?
> > Your service implements ServiceLifecycle. Axis should call your init()
> > method, passing you a reference to the ServletContext. From that you can
> > get
> > servlet initialization parameters (like filenames) that you specified in
> > web.xml. I'm new, too, so don't take my input as a good way to do
> > things!
> >
> > public class MyService implements ServiceLifecycle {
> >   public void init(java.lang.Object context)
> >     throws ServiceException {
> >
> >    ServletEndpointContext ctx = (ServletEndpointContext)context;
> >    ServletContext servletContext = ctx.getServletContext();
> >    //get filename specified in web.xml and open it
> >    String filename = servletContext.getInitParameter("filename");
> >    InputStream is = servletContext.getResourceAsStream(filename);
> >   }
> > }
> >
> > Eric H. Jung
> >
> > On Wednesday 13 November 2002 08:18 am, Ben Souther wrote:
> > > Does Axis have a mechanism for passing initialization parameters to a
> > > webservice class?