Init parameter in web.xml throwing an error..?

OK.. this is probably going to sound strange, but here goes:
Here is my entry in the web.xml:
<servlet>
          <servlet-name>ServletTestRunner</servlet-name>
          <servlet-class>
               org.apache.cactus.server.runner.ServletTestRunner
          </servlet-class>
     </servlet>
     <servlet-mapping>
          <servlet-name>ServletTestRunner</servlet-name>
          <url-pattern>/ServletTestRunner</url-pattern>
     </servlet-mapping>Everything works fine - I pull up the servlet with the following URL (http://localhost:7001/CDCAppWeb/ServletTestRunner?suite=com.testcases.decision.service.SendCreditRequestBeanTest)
, and receive the results in XML format. However, if I change the web.xml to have the following:
     <servlet>
          <servlet-name>ServletTestRunner</servlet-name>
          <servlet-class>
               org.apache.cactus.server.runner.ServletTestRunner
          </servlet-class>
          <init-param>
               <param-name>xsl-stylesheet</param-name>
               <param-value>cactus-report.xsl</param-value>
          </init-param>
     </servlet>(notice the cactus-report.xsl init-param entry) - the servlet does not work. Actually, NONE of the other servlets in my application work when I put in this init-param for the ServletTestRunner. I have verified that the xsl is in the classpath (WEB-INF/classes).
What I am missing... any ideas?

I know what the problem is. If you call servlet with the default URL (http://host/app/servlet/package.Servlet) than Servlet DOES NOT read init parameters. I don't know why it was designed this way.
To make servlet read init parameters, you have to assign it a name and then call it with that name, like this:
<servlet>
<servlet-name>ServletName</servlet-name>
<servlet-class>package.ServletClass</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletName</servlet-name>
<url-pattern>/app/path/ServletName</url-pattern>
</servlet-mapping>
You can then call servlet using path specified in url-pattern and read init parameters in the normal way.

Similar Messages

  • Init-params in web.xml are not loaded (Tomcat 4)

    Hello all...
    I register a servlet in webapps/<my-servlet>/WEB-INF/web.xml file, and pass 1 <init-param> tag. The file gets parsed (I know because when I made errors tomcat complained during initialization). However, when in the init method of the servlet I try to access this parameter, its not there. In fact, the servlet has NO init params at all.
    =================================================
    I have the following web.xml file
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!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>XServlet</servlet-name>
    <servlet-class>com.fxcm.xml.xengine.xdas.XServlet</servlet-class>
    <init-param>
    <param-name>xengine.configFile</param-name>
    <param-value>c:/projects/re/das.config/config.xng</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
         <servlet-name>XServlet</servlet-name>
         <url-pattern>/xservlet</url-pattern>
    </servlet-mapping>
    </web-app>
    =======================================================
    I have the following servlet
    * XServlet.java
    * Created on May 6, 2002, 1:17 PM
    package com.fxcm.xml.xengine.xdas;
    import javax.servlet.*;
    import javax.servlet.http.HttpServlet;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletConfig;
    import java.util.Enumeration;
    import com.fxcm.xml.xengine.XEngine;
    public class XServlet extends HttpServlet{
    /** Initiates new XServlet */
    public void init(ServletConfig config)
    throws ServletException
              for (Enumeration e = config.getInitParameterNames(); e.hasMoreElements();){
    //This statement never gets printed because the loop never enters here since there are no init parameters
                   System.out.println(e.nextElement());
    super.init(config);
    String str = config.getInitParameter("xengine.configFile");
    System.out.println(str);
    XEngine.init(str.trim()); //This line throws NullPointer, because str is null since there are no initParameters.
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException{
    // res.setContentType( );
              System.out.println("Got post request in XServlet");
    PrintWriter out = res.getWriter();
    out.println(XEngine.process(req.getInputStream()));
    out.flush();
    out.close();
    ================================================================
    I get the follwoing error in the browser:
    type Exception report
    message Internal Server Error
    description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
         at com.fxcm.xml.xengine.xdas.XServlet.init(Unknown Source)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:918)
         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:655)
         at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:400)
    Please help.
    Thank you,
    Elana

    I know what the problem is. If you call servlet with the default URL (http://host/app/servlet/package.Servlet) than Servlet DOES NOT read init parameters. I don't know why it was designed this way.
    To make servlet read init parameters, you have to assign it a name and then call it with that name, like this:
    <servlet>
    <servlet-name>ServletName</servlet-name>
    <servlet-class>package.ServletClass</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ServletName</servlet-name>
    <url-pattern>/app/path/ServletName</url-pattern>
    </servlet-mapping>
    You can then call servlet using path specified in url-pattern and read init parameters in the normal way.

  • Access parameter from web.xml

    <servlet>
    <servlet-name>serverText</servlet-name>
    <servlet-class>abc</servlet-class>
    <init-param>
    <param-name>serverParam</param-name>
    <param-value>parameter</param-value>
    </init-param>
    </servlet>
    Hi, above is what i defined in my web.xml.
    i want to know how to get the serverParam from my jsp file.
    i tried to use String param = pageContext.getServletConfig().getInitParameter("serverParam");
    but i got null.
    please help me.
    thanks

    hi,
    well all jsps are compiled to servlets before running anyway, well if you using a jsp you can still do the
    String param = getInitParameter("serverParam");
    you could do this in the jspInit method
    public void jspInit()
    String param = config.getInitParameter("serverParam");
    // config is the implicit ServletConfig object
    The getInitParameter method is actually defined in the javax.servlet.ServletConfig class, the ServetConfig object is available as an implicit object by name config in a jsp page with page-level scope). well hope this was useful.
    Cheerz

  • Access context parameter in web.xml

    Hi, all. I add a entry into Context Initialization parameter at tab Application in file web.xml with name: path and value img/product. I don't know how to get the context parameter. I want access the context by EL in file .jspx or .jsf, as #{path} but error. Can anyone help me.Thanks.

    Hi,
    have a go with
    #{initParam['param_name_here']}"
    alternatively
    #{facesContext.externalContext.initParameterMap['param_name_here']}
    Frank

  • Init parameters in web.xml file

    Hi,
    I have a query related to the init parameters defined in web.xml file.
    When does a servlet read these parameters?
    Also, how does servlet use these parameters while processing the client's request?
    Thanks in advance......

    hai,
    In order to make servlet flexible we must avoid hard-coding(writing-directly).so there are two ways in that one one way is init param's.
    create ServletConfig object as show below
    ServletConfig config=getServletConfig();then retrieve the init param value in to your servlet us getInitParameter(..) method as show below
    String something=config.getInitParameter("init param name");

  • Realising global Parameters like init-param in web.xml

    Hallo,
    I have a question:
    How can I implement own parameters in a StudioCreator-application.
    I have tried to edit the web.xml, first time it works.
    (I read the parameters with ExternalContext.getInitParameter)
    But later the web.xml was rewrited by the IDE and my parameters are gone.
    Thanks for your help!
    Regards
    Wolfgang

    Hallo,
    I tried both. First the one in build. An than the one in src.
    If I change the name or the Page (with rename)
    my entries in the web.xml disappear.
    My entries are:
    <context-param>
    <param-name>ldap_url_primary</param-name>
    <param-value>ldap://WW004.SIEMENS.NET:389</param-value>
    </context-param>
    <context-param>
    <param-name>domaene</param-name>
    <param-value>WW004.SIEMENS.NET</param-value>
    </context-param>
    <!-- Faces Servlet -->
    Thanks,
    Wolfgang

  • JSR 168 portlet based web service throwing an error ......

    Hi All,
    I am quite new to this whole new fusion concept.We are trying to build some web center based applications.
    I have downloaded jdev11g(Studio Edition Version 11.1.1.0.0)technolgy preview version and started following the pdf documentation that comes with it to build the web center based applications.
    As given in the docummentation i have built a JSR 168 Java Portlet through the wizard in Jdeveloper.
    2:Created a java bean to store the portlet information,added some business logic to the portlet.
    3:Deployed the portlet application in the preconfigured OC4J that is shipped with the jdeveloper.
    4:When i test the webservice from within the http analyzer in jdeveloper by invoking the web service i get a response like this:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><env:Fault>
    <faultcode>env:Server</faultcode>
    <faultstring>no serializer is registered for (interface javax.xml.soap.SOAPElement, {urn:oasis:names:tc:wsrp:v2:types}getPortletPropertyDescriptionResponse)</faultstring><faultactor/></env:Fault></env:Body></env:Envelope>
    5:If i then try to register the WSRP Portlet producer to my deployed application i get the the 500 status error which states that it cannot register the portlet as it could not connect to the host because the application is not deployed correctly or the producer container is not running or that the host is beyond a firewall.
    It cannot be that it cannot connect to the host because of firewall ,the pre configured oc4j is also running which leaves the option of the application not being deployed correctly in the server.!!
    While i try to register the portlet the preconfigured oc4j log displays the error in point 4:
    Any help would be great as i have no clue what went wrong in the deployment because everything is so wizard driven...
    Looking for some urgent help...as we are in the process of building prototypes for the customer!!!

    Hi user,
    I think it best not to use the 11g preview versions anymore. To build WebCenter applications, you should use the last 10g version, which is 10.1.3.4. 11g Production has superseded the preview versions, and in that there is no webcenter support, as everything is now migrated towards weblogic.
    So please try to follow your tutorial in 10g.
    Regards,
    Jeroen van Veldhuizen
    Redora

  • error-page in web.xml not working

    In my web.xml I have
    <error-page>
    <exception-type>java.lang.NullPointerException</exception-type>
    <location>/error.jsp</location>
    </error-page>
    I checked the page works by doing a /context/error.jsp and
    the page displays fine (it is a simple jsp page).
    I hit a struts action that gives me this in the std output.
    06/29 10:48:24 error
    [1]java.lang.NullPointerException
    at
    com.pearson.gs.cms.business.LoginService.verifyPassword(LoginService.java:232)
    at
    com.pearson.gs.cms.action.LoginAction.performCMSAction(LoginAction.java:92)
    at
    com.pearson.gs.cms.action.BaseCMSAction.execute(BaseCMSAction.java:48)
    at
    org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
    at
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
    at
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    at
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
    at
    jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    at
    jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:259)
    at
    jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
    at
    jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
    at
    jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
    [0]javax.servlet.ServletException
    at
    org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
    at
    org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
    at
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
    at
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    at
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
    at
    jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    at
    jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:259)
    at
    jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
    at
    jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
    at
    jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
    I get a 500 error page instead of my /error.jsp page.
    I tried adding
    <error-page>
    <error-code>500</error-code>
    <location>/error.jsp</location>
    </error-page>
    but that doesn't work either.
    JRun 4.0
    Updater 6
    JDK 1.4.2
    Struts 1.2.8
    Any ideas what to try?

    a. Override your skeletons error.jsp to forward/redirect to your page.
    or
    b. If you primarily use pageflow portlets Define a shared flow which has an exception handling method and direct it to your page. Reference the shared flow in each of your controllers (i think global.app is deprecated in 10 otherwise you could do this there). this lets you log some additional information, plus gives you the added flexibility of dealing with different exception types
    or
    c. Override the path to error.jsp in your portlets properties (havent tested)
    Note if you are using servlets etc you still need your web.xml java.lang.Exception entry. The reason it doesnt get picked up is because the portal framework is handling the exception
    Edited by: deepshet on Dec 22, 2008 8:12 PM

  • ADF/Webcenter Portal Error Page configuration in web.xml

    Hi All,
    I am using jdeveloper version 11.1.1.6.0.
    I set two error pages in my application by following web.xml entries.
      <error-page>
        <error-code>404</error-code>
        <location>/oracle/webcenter/portalapp/pages/AfError.html</location>
      </error-page>
      <error-page>
        <error-code>503</error-code>
        <location>/oracle/webcenter/portalapp/pages/SiteMaintenance.html</location>
      </error-page>but it does not divert to the AfError.html page but shows 404 error.
    How to solve this.
    Is it possible to set .jspx page in location attribute also.
    Any help is appreciated.
    Require as early as possible

    Hi,
    this should be asked on the WebCenter forum. However, how likely is it that your error page also causes a 404 error? The message in you web.xml file are for site not found and site not available. So unless you redirect to something that is accessible you wont be able to tell whether it works or not
    Frank

  • Handling 404 error through web.xml

    In my application i made the following entry in web.xml:
      <error-page>
        <error-code>404</error-code>
        <location>/error.jspx</location>
      </error-page>
    error.jspx is a jspx file and exist in the public_html folder and has following entry:
    <f:view>
        <af:document id="d1">
          <af:form id="f1">
          <af:outputText value="Hello There error occured" id="ot_11" />
          </af:form>
        </af:document>
      </f:view>
    when a 404 occurs in the application, i am getting following application in the log:
    <[ServletContext@3806419[app:j2ee-app module:retailer path:/retailer spec-version:2.5]] error-page location: "/error.jspx" for the error-code: "404" does not exist. Serving the default error page.>
    Any suggestion what to do next?

    on more thing,
    404 errors are handled by web.xml using following:
    <error-page>
       <error-code>404</error-code>
       <location>/login/404errorPage404.html</location>
    </error-page>
    but in case of 500 errors or nullpointers i treid a no of options, but neither one  worked:
    <error-page>
    <error-code>500</error-code>
       <location>/login/500errorPage500.html</location>
    </error-page>
    <error-page>
       <exception-type>javax.el.ELException</exception-type>
       <location>/login/500errorPage500.html</location>
    </error-page>
    <error-page>
       <exception-type>java.lang.Exception</exception-type>
       <location>/login/500errorPage500.html</location>
    </error-page>
    <error-page>
       <exception-type>java.lang.Throwable</exception-type>
       <location>/login/500errorPage500.html</location>
    </error-page>
    Any advise?

  • Problem in Web.xml.........

    Hi to All,
    I installed the eval version of Crystal Reporst XI, created an example report with it and now I want to call my report from JSF Page.i followed the crxi_startup_guide_for_j2ee.i got the error in 'web.xml' file.the error is:
    "cvc-complex-type.2.4.a: Invalid content was found starting with element 'env-entry-value'. One of '{"http://java.sun.com/xml/ns/j2ee":env-entry-type}' is expected"
    here i shows my entry in web.xml file:
    <env-entry>
    <env-entry-name>jdbc/mydatabase name</env-entry-name>
    <env-entry-value>!com.microsoft.jdbc.sqlserver.SQLServerDriver!jdbc:odbc:mydatabase name</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>
    im unable to get what was the problem.my environment is Tomcat 5.0.28,SQL2000.
    i created that report using ODBC connection.is it correct?suppose if i have to connect using JNDI means how to achive this?
    can any one get me out of this please!!
    Thanks in Advance,
    --RK                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    This is my web.xml file........
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <env-entry>
    <env-entry-name>jdbc/IMDB</env-entry-name>
    <env-entry-value>!com.microsoft.jdbc.sqlserver.SQLServerDriver!jdbc:odbc:IMDB</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>
    <context-param>
    <param-name>com.sun.faces.verifyObjects</param-name>
    <param-value>false</param-value>
    </context-param>
    <context-param>
    <param-name>com.sun.faces.validateXml</param-name>
    <param-value>true</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
    </context-param>
    <context-param>
    <param-name>crystal_image_uri</param-name>
    <param-value>crystalreportviewers11</param-value>
    </context-param>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
         <welcome-file>
    index.jsp
    </welcome-file>
    </welcome-file-list>
    </web-app>
    Thnx,
    Rk

  • How to initialized a variable in java file by taking the value from web.xml

    suppose i declare parameter in web.xml file
    i want to access if from a java file .
    how can i do this . plz help me its urgent...............

    In your Servlet class you can use the getInitParameter("configfile") method.

  • Simplest way to modify properties from web.xml

    I'm testing a very small Web application which uses init-params in web.xml for configuration. For manual testing purposes, I need to be able to change the values of these as easily as possible, preferably from the WebLogic admin console. (I can do it from the console on Websphere App Server, and on Tomcat by editing a file which is immediately re-read.) We don't currently use deployment descriptors in any way and this is only a test of basic code functionality, not of deployment mechanisms, so the change can be as quick-and-dirty as you like. I'm using WebLogic v10 on Linux.
    Thanks,
    Pete

    Another option for you may be to deploy the application in exploded format and use weblogic.Deployer or WLST to redeploy the application :
    http://edocs.bea.com/wls/docs100/deployment/autodeploy.html
    This would be slightly more similar to your Tomcat deployment, but requires a few more steps.

  • Struts web xml

    Hi there,
    I want to define my own error pages. Someone told me that it's possible to define them in web.xml
    I use this somewhere in my code:
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    I want to keep this, but I want to make my own styled page.
    Can someone help me?

    in your web.xml for each error
    <error-page>
    <error-code>404 (500,...)</error-code>
    <location>anurlto your custom page </location>
    </error-page>

  • Impossible to get the Sun NS and XSD to validate my web.xml

    Hello,
    I'm having a problem getting the namespace and schema to validate my web.xml file. Three days ago, everythings were working fine, but since friday I can't get the XSD.
    The top of my web.xml looks like this :
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    >When I try to validate my web.xml, I got error like this :
    s4s-elt-character: Non-whitespace characters are allowed ...I've recently seen other topics like this, but I'm not sure it's the same issue.
    Is it a known issue? What can I do to validate my web.xml? Are there mirrors for this XSD?
    Best Regards.
    Message was edited by:
    Arlo

    Please help, I still have the problem and it seems it's a known issue :
    http://dev.eclipse.org/newslists/news.eclipse.webtools/msg03484.html

Maybe you are looking for

  • Itouch does not recover - error 1611

    I bought a new itouch. When switching on: The black screen with the white apple appeared, but only for a few seconds, then it disappeared. Trying to recover using reset and re-installing the software caused the error described in the apple help docs:

  • Health & Money Variable in Game

    Hi, I'm working on a game where I need to have a variable for money and a variable for Health, or in my case, I call it Energy. Most tutorials I'm finding are in AS2 and the AS3 ones are not this basic thing that I need. Basically, I have an item sho

  • How to make the life easier when sound file may be changed in future?

    Hello, friends, I have about 600 sound files (total about 10MB), which will be used by thousands of .swf files. Each .swf file may use only a few of those 600 sound files. I know I can load those sound files into each .swf as needed. However, since t

  • Patches Apply After 10g report migration

    Hi All, I am migrated 10g report into 11g.After that can i install 11g patches?It will impact any report issues or ? It will impact means i will loss the reports. Thanks Gram

  • How to install the socket transport?

    hi i have build the sample-transport "OSB_ORACLE_HOME/samples/servicebus/sample-transport", and execute the following command: ant build-jar, after show the message: "..../Oracle_OSB1/samples/servicebus/sample-transport/build.xml:7: taskdef class web