Servlet init parameters common to more servlets

Hi all,
I have a set of servlets using each one some init parameters.
Some of these parameters are common to a certain number of servlets.
Does exist a place where to put this init-parameter, avoiding to repeat these values
in all the definions of the servlets in the web xml file (I am using Tomcat 4.x) ?
thanks in advance,
Andrea

instead of adding a init-param to the servlet tag you also might add a context-param tag to the web-app.
please see the web-app DTD file to see the exact structure (i think it's named context-param and the child-elements are similar to those of init-param - but sorry - i'm not 100% sure).
inside the servlet you could then do something like the following:
// this = e.g. a HttpServlet
String param = this.getServletConfig().getInitParameter("your_param");
if(param == null) {
  param = this.getServletContext().getInitParameter("your_param");
  if(param == null) {
    throw new ServletException("Missing parameter");
}result:
servlet searches the servlet specific init parameters
if the parameter could be found it will be used (servlet param "overwrites" global param)
else the servlet searches the webapp specific init parameter
if the parameter could be found it will be used
else the servlet throws an exception

Similar Messages

  • How do I get a servlet configured with init parameters

    When I try to add a set of <init-param> parameters to a servlet it seems
              like the weblogic server is trying to load it as a bean, which since its not
              a bean it can't do. I get the following error trace when I start the
              server:
              C:\bea\wlserver6.0sp1>set
              PATH=.\bin;C:\orant\bin;C:\WINNT\system32;C:\WINNT;C:\
              WINNT\System32\Wbem;C:\MSSQL7\BINN;C:\Program Files\Microsoft Visual
              Studio\Comm
              on\Tools\WinNT;C:\Program Files\Microsoft Visual
              Studio\Common\MSDev98\Bin;C:\Pr
              ogram Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft
              Visu
              al Studio\VC98\bin;"C:\Program
              Files\Mts";C:\PROGRA~1\NETWOR~1\PGP;C:\MSSQL7\BIN
              N;C:\jdk1.2.2\bin;
              weblogic.xml.dom.ChildCountException
              at weblogic.xml.dom.DOMUtils.getElementByTagName(DOMUtils.java:147)
              at weblogic.xml.dom.DOMUtils.getValueByTagName(DOMUtils.java:128)
              at
              weblogic.servlet.internal.dd.ParameterDescriptor.<init>(ParameterDesc
              riptor.java:45)
              at
              weblogic.servlet.internal.dd.ServletDescriptor.<init>(ServletDescript
              or.java:79)
              at
              weblogic.servlet.internal.dd.WebAppDescriptor.<init>(WebAppDescriptor
              .java:171)
              at
              weblogic.servlet.internal.dd.DescriptorLoader.initialize(DescriptorLo
              ader.java:288)
              at
              weblogic.servlet.internal.dd.DescriptorLoader.<init>(DescriptorLoader
              .java:230)
              at
              weblogic.servlet.internal.HttpServer.loadWARContext(HttpServer.java:4
              73)
              at
              weblogic.servlet.internal.HttpServer.loadWebApp(HttpServer.java:421)
              at weblogic.j2ee.WebAppComponent.deploy(WebAppComponent.java:74)
              at weblogic.j2ee.Application.addComponent(Application.java:126)
              at weblogic.j2ee.J2EEService.addDeployment(J2EEService.java:115)
              at
              weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(Depl
              oymentTarget.java:283)
              at
              weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(Depl
              oymentTarget.java:109)
              at
              weblogic.management.mbeans.custom.WebServer.addWebDeployment(WebServe
              r.java:76)
              at java.lang.reflect.Method.invoke(Native Method)
              at
              weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMB
              eanImpl.java:562)
              at
              weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl
              .java:548)
              at
              weblogic.management.internal.ConfigurationMBeanImpl.invoke(Configurat
              ionMBeanImpl.java:285)
              at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              55)
              at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              23)
              at
              weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:437)
              at
              weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:178)
              at $Proxy27.addWebDeployment(Unknown Source)
              at
              weblogic.management.configuration.WebServerMBean_CachingStub.addWebDe
              ployment(WebServerMBean_CachingStub.java:985)
              at
              weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(Depl
              oymentTarget.java:269)
              at
              weblogic.management.mbeans.custom.DeploymentTarget.addDeployments(Dep
              loymentTarget.java:233)
              at
              weblogic.management.mbeans.custom.DeploymentTarget.updateServerDeploy
              ments(DeploymentTarget.java:194)
              at
              weblogic.management.mbeans.custom.DeploymentTarget.updateDeployments(
              DeploymentTarget.java:158)
              at java.lang.reflect.Method.invoke(Native Method)
              at
              weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMB
              eanImpl.java:562)
              at
              weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl
              .java:548)
              at
              weblogic.management.internal.ConfigurationMBeanImpl.invoke(Configurat
              ionMBeanImpl.java:285)
              at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              55)
              at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              23)
              at
              weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:437)
              at
              weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:178)
              at $Proxy26.updateDeployments(Unknown Source)
              at
              weblogic.management.configuration.ServerMBean_CachingStub.updateDeplo
              yments(ServerMBean_CachingStub.java:2299)
              at
              weblogic.management.mbeans.custom.ApplicationManager.startConfigManag
              er(ApplicationManager.java:240)
              at
              weblogic.management.mbeans.custom.ApplicationManager.start(Applicatio
              nManager.java:122)
              at java.lang.reflect.Method.invoke(Native Method)
              at
              weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMB
              eanImpl.java:562)
              at
              weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl
              .java:548)
              at
              weblogic.management.internal.ConfigurationMBeanImpl.invoke(Configurat
              ionMBeanImpl.java:285)
              at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              55)
              at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              23)
              at
              weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:437)
              at
              weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:178)
              at $Proxy19.start(Unknown Source)
              at
              weblogic.management.configuration.ApplicationManagerMBean_CachingStub
              .start(ApplicationManagerMBean_CachingStub.java:435)
              at
              weblogic.management.Admin.startApplicationManager(Admin.java:1030)
              at weblogic.management.Admin.finish(Admin.java:491)
              at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:429)
              at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:170)
              at weblogic.Server.main(Server.java:35)
              >
              <Apr 3, 2001 3:42:32 PM EDT> <Notice> <WebLogicServer> <WebLogic Server
              started>
              <Apr 3, 2001 3:42:32 PM EDT> <Notice> <WebLogicServer> <ListenThread
              listening o
              n port 7001>
              <Apr 3, 2001 3:42:32 PM EDT> <Notice> <WebLogicServer> <SSLListenThread
              listenin
              g on port 7002>
              <Apr 3, 2001 3:42:38 PM EDT> <Error> <HTTP> <HttpServer(1112581,null default
              ctx
              ,ajrserver) found no context for "GET /CommonOpinionAdmin2?verifyinstall=
              HTTP/1
              .1". This should not happen unless the default context failed to deploy.>
              The distribution file is not a WAR file, but a JAR file. I need to to just
              do what it does if I don't specify any init-param's which is to pass them
              when the servlet does get loaded, or load it as a servlet from a jar file
              instead of a bean.
              How do I configure weblogics to run my servlet with init parameters.
              Thank You,
              Anthony Rizzolo
              

    I'll answer my own problem. It turns out that you can't put multiple
              <param-name> and <param-value> pairs within a single <init-param>. I
              assumed that you could since none of the examples had more than one
              parameter I didn't realize that you had to specify multiple <init-param>
              tags if you had multiple parameters.
              Anthony Rizzolo
              "Anthony Rizzolo" <[email protected]> wrote in message
              news:[email protected]...
              > When I try to add a set of <init-param> parameters to a servlet it seems
              > like the weblogic server is trying to load it as a bean, which since its
              not
              > a bean it can't do. I get the following error trace when I start the
              > server:
              >
              > C:\bea\wlserver6.0sp1>set
              > PATH=.\bin;C:\orant\bin;C:\WINNT\system32;C:\WINNT;C:\
              > WINNT\System32\Wbem;C:\MSSQL7\BINN;C:\Program Files\Microsoft Visual
              > Studio\Comm
              > on\Tools\WinNT;C:\Program Files\Microsoft Visual
              > Studio\Common\MSDev98\Bin;C:\Pr
              > ogram Files\Microsoft Visual Studio\Common\Tools;C:\Program
              Files\Microsoft
              > Visu
              > al Studio\VC98\bin;"C:\Program
              > Files\Mts";C:\PROGRA~1\NETWOR~1\PGP;C:\MSSQL7\BIN
              > N;C:\jdk1.2.2\bin;
              >
              > weblogic.xml.dom.ChildCountException
              > at
              weblogic.xml.dom.DOMUtils.getElementByTagName(DOMUtils.java:147)
              > at weblogic.xml.dom.DOMUtils.getValueByTagName(DOMUtils.java:128)
              > at
              > weblogic.servlet.internal.dd.ParameterDescriptor.<init>(ParameterDesc
              > riptor.java:45)
              > at
              > weblogic.servlet.internal.dd.ServletDescriptor.<init>(ServletDescript
              > or.java:79)
              > at
              > weblogic.servlet.internal.dd.WebAppDescriptor.<init>(WebAppDescriptor
              > .java:171)
              > at
              > weblogic.servlet.internal.dd.DescriptorLoader.initialize(DescriptorLo
              > ader.java:288)
              > at
              > weblogic.servlet.internal.dd.DescriptorLoader.<init>(DescriptorLoader
              > .java:230)
              > at
              > weblogic.servlet.internal.HttpServer.loadWARContext(HttpServer.java:4
              > 73)
              > at
              > weblogic.servlet.internal.HttpServer.loadWebApp(HttpServer.java:421)
              > at weblogic.j2ee.WebAppComponent.deploy(WebAppComponent.java:74)
              > at weblogic.j2ee.Application.addComponent(Application.java:126)
              > at weblogic.j2ee.J2EEService.addDeployment(J2EEService.java:115)
              > at
              > weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(Depl
              > oymentTarget.java:283)
              > at
              > weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(Depl
              > oymentTarget.java:109)
              > at
              > weblogic.management.mbeans.custom.WebServer.addWebDeployment(WebServe
              > r.java:76)
              > at java.lang.reflect.Method.invoke(Native Method)
              > at
              > weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMB
              > eanImpl.java:562)
              > at
              > weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl
              > .java:548)
              > at
              > weblogic.management.internal.ConfigurationMBeanImpl.invoke(Configurat
              > ionMBeanImpl.java:285)
              > at
              > com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              > 55)
              > at
              > com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              > 23)
              > at
              > weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:437)
              > at
              > weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:178)
              > at $Proxy27.addWebDeployment(Unknown Source)
              > at
              > weblogic.management.configuration.WebServerMBean_CachingStub.addWebDe
              > ployment(WebServerMBean_CachingStub.java:985)
              > at
              > weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(Depl
              > oymentTarget.java:269)
              > at
              > weblogic.management.mbeans.custom.DeploymentTarget.addDeployments(Dep
              > loymentTarget.java:233)
              > at
              > weblogic.management.mbeans.custom.DeploymentTarget.updateServerDeploy
              > ments(DeploymentTarget.java:194)
              > at
              > weblogic.management.mbeans.custom.DeploymentTarget.updateDeployments(
              > DeploymentTarget.java:158)
              > at java.lang.reflect.Method.invoke(Native Method)
              > at
              > weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMB
              > eanImpl.java:562)
              > at
              > weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl
              > .java:548)
              > at
              > weblogic.management.internal.ConfigurationMBeanImpl.invoke(Configurat
              > ionMBeanImpl.java:285)
              > at
              > com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              > 55)
              > at
              > com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              > 23)
              > at
              > weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:437)
              > at
              > weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:178)
              > at $Proxy26.updateDeployments(Unknown Source)
              > at
              > weblogic.management.configuration.ServerMBean_CachingStub.updateDeplo
              > yments(ServerMBean_CachingStub.java:2299)
              > at
              > weblogic.management.mbeans.custom.ApplicationManager.startConfigManag
              > er(ApplicationManager.java:240)
              > at
              > weblogic.management.mbeans.custom.ApplicationManager.start(Applicatio
              > nManager.java:122)
              > at java.lang.reflect.Method.invoke(Native Method)
              > at
              > weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMB
              > eanImpl.java:562)
              > at
              > weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl
              > .java:548)
              > at
              > weblogic.management.internal.ConfigurationMBeanImpl.invoke(Configurat
              > ionMBeanImpl.java:285)
              > at
              > com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              > 55)
              > at
              > com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              > 23)
              > at
              > weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:437)
              > at
              > weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:178)
              > at $Proxy19.start(Unknown Source)
              > at
              > weblogic.management.configuration.ApplicationManagerMBean_CachingStub
              > .start(ApplicationManagerMBean_CachingStub.java:435)
              > at
              > weblogic.management.Admin.startApplicationManager(Admin.java:1030)
              > at weblogic.management.Admin.finish(Admin.java:491)
              > at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:429)
              > at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:170)
              > at weblogic.Server.main(Server.java:35)
              > >
              > <Apr 3, 2001 3:42:32 PM EDT> <Notice> <WebLogicServer> <WebLogic Server
              > started>
              >
              > <Apr 3, 2001 3:42:32 PM EDT> <Notice> <WebLogicServer> <ListenThread
              > listening o
              > n port 7001>
              > <Apr 3, 2001 3:42:32 PM EDT> <Notice> <WebLogicServer> <SSLListenThread
              > listenin
              > g on port 7002>
              > <Apr 3, 2001 3:42:38 PM EDT> <Error> <HTTP> <HttpServer(1112581,null
              default
              > ctx
              > ,ajrserver) found no context for "GET /CommonOpinionAdmin2?verifyinstall=
              > HTTP/1
              > .1". This should not happen unless the default context failed to deploy.>
              >
              > The distribution file is not a WAR file, but a JAR file. I need to to
              just
              > do what it does if I don't specify any init-param's which is to pass them
              > when the servlet does get loaded, or load it as a servlet from a jar file
              > instead of a bean.
              >
              > How do I configure weblogics to run my servlet with init parameters.
              >
              > Thank You,
              > Anthony Rizzolo
              >
              >
              

  • Providing init parameters to a servlet portal component

    I'm creating a portalcomponent based on a servlet. So I have the following declaration in my portalapp.xml:
          <component-config>
            <property name="ComponentType" value="servlet"/>
            <property name="ClassName" value="test.TestServlet"/>
    Now I want to provide standard init-parameters (as defined in a servlets' web.xml) to this servlet, but I can't find any documentation describing how to do this. Standard profile parameters do not get through to the ServletConfig or ServletContext.
    Any help will be appreciated.
    Regards,
    Marnix

    seems simple enough right
    but i don't get this to work.
    private Vector parameterNames = null;
    public void init(){
    parameterNames = new Vector();
    for(Enumeration e = this.getInitParameterNames(); e.hasMoreElements() ;) {
    parameterNames.add(e.nextElement());

  • Can't define init parameters for multiple servlets

    I want to define init parameters for two servlets in the web.xml file but i only get null for my Login servlet
    <web-app>
    <servlet>
    <servlet-name>
    RSServlet
    </servlet-name>
    <servlet-class>
    RoadSafe.Servlet.RSServlet
    </servlet-class>
    <init-param>
    <param-name>serverip</param-name>
    <param-value>localhost</param-value>
    </init-param>
         <load-on-startup>
              2
         </load-on-startup>
    </servlet>
         <servlet>
    <servlet-name>
    Login
    </servlet-name>
    <servlet-class>
    RoadSafe.AdMisc.Login
    </servlet-class>
    <init-param>
    <param-name>serverip2</param-name>
    <param-value>localhost</param-value>
    </init-param>
         <load-on-startup>
              1
         </load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>
    RSServlet
    </servlet-name>
    <url-pattern>
    /RSServlet
    </url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>
    Login
    </servlet-name>
    <url-pattern>
    /Login
    </url-pattern>
    </servlet-mapping>
    </web-app>

    In the code for you Login servlet, are you using the name "serverip2" to access the initial parameter ?
    Thats the name you have used in the web.xml file.

  • Different behaviour on servlet w/o servlet-mapping and init parameters

    I was playing around and found, that the init-parameter of a servlet is always null if there is no servlet mapping. I did not define a servlet mapping because I used the servlet only for for (named) dispatching (client usage should not be allowed).
    web.xml:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app 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" version="2.4">
      <servlet>
        <servlet-name>InitParamServlet</servlet-name>
        <servlet-class>test.InitParamServlet</servlet-class>
        <init-param>
          <param-name>param1</param-name>
          <param-value>value1</param-value>
        </init-param>
      </servlet>
      <servlet-mapping>
        <servlet-name>InitParamServlet</servlet-name>
        <url-pattern>*.initparam</url-pattern>
      </servlet-mapping>
    </web-app>
    InitParamServlet.java:
    package test;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class InitParamServlet extends HttpServlet{
      private static final long serialVersionUID = 1L;
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        pw.write(getServletName());
        pw.write(": param1=" + getInitParameter("param1"));
    }The URL http://localhost:8080/xxx/servlet/test.InitParamServletreturns org.apache.catalina.INVOKER.test.InitParamServlet: param1=null
    (on Tomcat), and the call to the same servlet with URL http://localhost:8080/xxx/test.initparamreturns InitParamServlet: param1=value1 instead (the correct init parameter value)!
    The same happens with jetty. This looks strange for me; I would expect the same behaviour for the servlet (independent from servlet-mapping-tag in the web.xml).

    When you call the url
    http://localhost:8080/xxx/servlet/test.InitParamServlet
    you are actually calling the invoker servlet that is defined in the default conf/web.xml. If you look at this web.xml file you will see that the invoker is mapped with the pattern "/servlet/*" which maps to the above url. The request goes to this servlet which parses the url and then calls the InitParamServlet class.
    When you call the url
    http://localhost:8080/xxx/test.initparam
    you are matching the url pattern you defined in the WEB-INF/web.xml file ("*.initparam"). This time the request goes to servlet instance that you defines in the servlet naming tags as "InitParamServlet" and since you defined init params they are populated.
    Note that these urls will also match the "*.initparam" pattern
    http://localhost:8080/xxx/XXXXX.initparam
    http://localhost:8080/xxx/badpackage.initparam
    http://localhost:8080/xxx/A.initparam
    Most people would have simplely defined the second servlet mapping as "initparam" and accessed the servlet with the url
    http://localhost:8080/xxx/initparam

  • Servlet init block doesn't work with getServletContext().getRequestDispat..

    Hi Everyone,
    I am getting null pointer exception when i have coded init method inside my servlet(inside that i am fetching init parameter passed from web,xml file) and while getting requestdispatcher from context.
    if i get requestdispatcher from request then it works fine. i dont understand reason behind this behaviour.
    please give your valueable comment.
    find code below:
    public void init(ServletConfig config) throws ServletException
    enum1 = config.getInitParameterNames();
    while(enum1.hasMoreElements()){
    init_paramNm = (String)enum1.nextElement();
    init_paramVal = config.getInitParameter(init_paramNm);
    System.out.println("Name = "init_paramNm" and value = "+init_paramVal);
    getting null pointer exception with this
    RequestDispatcher rd = getServletContext().getRequestDispatcher("/ObjJSPtoServlet.jsp");
    rd.forward(request, response);
    work fine with
    RequestDispatcher rd = request.getRequestDispatcher("/ObjJSPtoServlet.jsp");
    rd.forward(request, response);

    public void init(ServletConfig config)
    throws ServletException
    Called by the servlet container to indicate to a servlet that the servlet is being placed into service. See Servlet.init(javax.servlet.ServletConfig).
    This implementation stores the ServletConfig object it receives from the servlet container for later use. When overriding this form of the method, call super.init(config). ...
    [More Info|http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/GenericServlet.html#init%28javax.servlet.ServletConfig%29]

  • Servlet init() method called multiple times

    We have a Servlet-based application which does lengthy initialization.
    We've noticed that when multiple requests arrive,
    but the Servlet's init() method has not returned yet
    for the first request, the application server calls init() multiple times.
    You can even see this with the Fortune sample
    Servlet. Starting the app server and sending 20 or 30
    simultaneous requests causes multiple Fortune Servlet init messages to appear in the kjs log.
    Why is this? We do not implement SingleThreadModel.
    Doesn't the J2EE 1.2 spec say init will be called
    only once?
    How do we prevent it?
    A Startup class which inits our
    Servlet?
    Or a synchronized block within our init method, with some checks of static member variables
    so that the initialization work only happens once?
    Or is there some kregedit magic or deployment descriptor change I could make?
    Again, it's not a SingleThreadModel issue, so don't
    point me there.
    This is iAS 6.0 SP4, on Solaris, by the way.

    Hi
    Yes,you are right. In iAS6.0 SP4 When multiple requests arrive,and the Servlet's init() method has not returned yet for the first request, the application server calls init()multiple times. This problem is resolved in iAS 6.5.
    There is no kregedit magic that will solve this problem.
    Right now the workaround is any of the solution you proposed. Or use iAS6.5. I have tested it with fortune.
    Please download it and check with your application.
    you can find free download at http://developer.iplanet.com/appserver/testdrive/testdrive_65.html
    Thanks

  • Portal servlet init() failed

    I sat Portal for s1as with remote existing s1ds (from another Identity server). Portal servlet failed when server started:
    CORE1116: Sun ONE Application Server 7.0
    INFO: CORE3016: daemon is running as super-user
    INFO: CORE5076: Using [Java HotSpot(TM) Server VM, Version 1.4.1_01] from [Sun Microsystems Inc.]
    INFO: JMS5023: JMS service successfully started. Instance Name = domain1_server1, Home = [usr/bin].
    INFO: JTS5014: Recoverable JTS instance, serverId = [100]
    INFO: RAR5060: Install JDBC Datasources ...
    INFO: JMS5015: Install JMS resources ...
    INFO: WEB0100: Loading web module [amserver] in virtual server [server1] at [amserver]
    INFO: WEB0100: Loading web module [amconsole] in virtual server [server1] at [amconsole]
    INFO: WEB0100: Loading web module [portal] in virtual server [server1] at [portal]
    SEVERE: WebModule[portal]: Servlet /portal threw load() exception
    javax.servlet.ServletException: Servlet.init() for servlet desktopServlet threw exception
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:949)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:813)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3346)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3592)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:638)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:345)
    at org.apache.catalina.startup.Embedded.start(Embedded.java:957)
    at com.iplanet.ias.web.WebContainer.start(WebContainer.java:426)
    at com.iplanet.ias.web.WebContainer.start(WebContainer.java:426)
    at com.iplanet.ias.web.WebContainer.startInstance(WebContainer.java:514)
    at com.iplanet.ias.server.J2EERunner.confPostInit(J2EERunner.java:170)
    ----- Root Cause -----
    com.sun.portal.desktop.context.ContextError: DSAMEConnection.getGlobalAttributes(): SunPortalDesktoa
    at com.sun.portal.desktop.context.DSAMEConnection.getGlobalAttributes(DSAMEConnection.java:)
    at com.sun.portal.desktop.context.DSAMEConnection.getGlobalAttributeMultiValueFromROC(DSAME)
    at com.sun.portal.desktop.context.DSAMEConnection.getGlobalAttributeFromROC(DSAMEConnection)
    at com.sun.portal.desktop.context.DSAMEServiceAppContext.getDebugContextClassName(DSAMEServ)
    at com.sun.portal.desktop.context.PSDesktopAppContext.getDebugContextClassName(PSDesktopApp)
    at com.sun.portal.desktop.context.PSDesktopAppContext.getNewDebugContext(PSDesktopAppContex)
    at com.sun.portal.desktop.context.PSDesktopAppContext.initDebugContext(PSDesktopAppContext.)
    at com.sun.portal.desktop.context.PSDesktopAppContext.init(PSDesktopAppContext.java:72)
    at com.sun.portal.desktop.context.PSDesktopContextFactory.initDesktopAppContext(PSDesktopCo)
    at com.sun.portal.desktop.context.PSDesktopContextFactory.init(PSDesktopContextFactory.java)
    at com.sun.portal.desktop.DesktopServlet.getDesktopContextFactory(DesktopServlet.java:189)
    at com.sun.portal.desktop.DesktopServlet.init(DesktopServlet.java:248)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:921)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:813)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3346)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3592)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:638)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1123)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:345)
    at org.apache.catalina.startup.Embedded.start(Embedded.java:957)
    at com.iplanet.ias.web.WebContainer.start(WebContainer.java:426)
    at com.iplanet.ias.web.WebContainer.startInstance(WebContainer.java:514)
    at com.iplanet.ias.server.J2EERunner.confPostInit(J2EERunner.java:170)
    com.iplanet.am.sdk.AMException: Unable to get service schema
    at com.iplanet.am.sdk.AMStoreConnection.getSchema(AMStoreConnection.java:699)
    at com.sun.portal.desktop.context.DSAMEConnection.getGlobalAttributes(DSAMEConnection.java:)
    at com.sun.portal.desktop.context.DSAMEConnection.getGlobalAttributeMultiValueFromROC(DSAME)
    at com.sun.portal.desktop.context.DSAMEConnection.getGlobalAttributeFromROC(DSAMEConnection)
    at com.sun.portal.desktop.context.DSAMEServiceAppContext.getDebugContextClassName(DSAMEServ)
    at com.sun.portal.desktop.context.PSDesktopAppContext.getDebugContextClassName(PSDesktopApp)
    at com.sun.portal.desktop.context.
    INFO: HTTP3072: HTTP listener http-listener-1 [http://sundevel.in.rosprint.ru:88] ready to accept rs
    startup: server started successfully
    What I have to do ?
    Regards.

    check amSDK and deploy.log for errors.
    located at /var/opt/SUNWam/debug
    It seems like your installation of portal was not successful in updating the directory server

  • OEM doesn't detect Servlet .init() failure!?!

    I'm trying to move some one-time initialization into a servlet .init() method and I wanted to see what would happen in OEM (Oracle Enterprise Manager) when this servlet's init() method failed (by throwing ServletException). I was hoping to see a Stop Sign or something...but instead OEM thinks everything is fine. Does anyone know how to make OEM aware of the actual state of the Servlets deployed under the OC4J containers it maintains?
    Bob
    package demos;
    import org.apache.struts.action.ActionServlet;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletContext;
    public class MyActionServlet extends ActionServlet {
    public MyActionServlet() { }
    public void init() throws ServletException {
    super.init();
    ServletContext sc = this.getServletContext();
    sc.setAttribute("AppScopeAttribute",
    "sc.toString()=" + sc.toString());
    sc.setAttribute("MyInitParam",
    this.getInitParameter("MyInitParam"));
    throw new ServletException(
    new Exception("This sucks...that sucks...everything sucks")
    }

    Maybe if I format the source better someone will render an opinion? I'm looking for ways to have the Oracle Enterprise Manager detect and report on .init() problems in my servlets. Here is a sample servlet that does nothing but throw and exception at .init() time. How can I configure OEM to react to and report this condition?
    package demos;
    import org.apache.struts.action.ActionServlet;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletContext;
    public class MyActionServlet extends ActionServlet {
      public MyActionServlet() { }
      public void init() throws ServletException {
        super.init();
        ServletContext sc = this.getServletContext();
        sc.setAttribute("AppScopeAttribute", "sc.toString()=" + sc.toString());
        sc.setAttribute("MyInitParam", this.getInitParameter("MyInitParam"));
        throw new ServletException( new Exception("This sucks...that sucks...everything sucks"));
    }

  • Configuring OEM to detect servlet.init() failures

    I'm trying to move some one-time initialization into a servlet .init() method and I wanted to see what would happen in OEM (Oracle Enterprise Manager) when this servlet's init() method failed (by throwing ServletException). I wrote a simple Servlet that does nothing but fail when it attempts to initialize. I was hoping to see a Stop Sign or something in OEM when I deloyed it, but instead OEM thinks everything is fine. Does anyone know how to make OEM aware of the actual state of the Servlets deployed under the OC4J containers?
    Bob
    package demos;
    import org.apache.struts.action.ActionServlet;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletContext;
    public class MyActionServlet extends ActionServlet {
    public MyActionServlet() { }
    public void init() throws ServletException {
    super.init();
    throw new ServletException( new Exception("I failed to init...DO SOMETHING!"));

    Maybe if I format the source better someone will render an opinion? I'm looking for ways to have the Oracle Enterprise Manager detect and report on .init() problems in my servlets. Here is a sample servlet that does nothing but throw and exception at .init() time. How can I configure OEM to react to and report this condition?
    package demos;
    import org.apache.struts.action.ActionServlet;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletContext;
    public class MyActionServlet extends ActionServlet {
      public MyActionServlet() { }
      public void init() throws ServletException {
        super.init();
        ServletContext sc = this.getServletContext();
        sc.setAttribute("AppScopeAttribute", "sc.toString()=" + sc.toString());
        sc.setAttribute("MyInitParam", this.getInitParameter("MyInitParam"));
        throw new ServletException( new Exception("This sucks...that sucks...everything sucks"));
    }

  • Iplanet kjs servlet init() method

    In iplanet is the servlet init method called in each KJS engine.
    I have a continous thread running in a servet.This is invoked by a webased hyperlink.Some times ther happens to be 2 threads running and results in false operations.Conflict b/w threads.
    Suspect one thread in each KJS is running.

    This is the incorrect forum for this question. Sun ONE Application Server 7 is a completely new appserver and does not have KJS related technologies or APIs. Please check AppServer 6 forum.
    HTH.
    Paul

  • Parameters in a mapped servlet in Tomcat

    I am using Tomcat 4.0.2/JDK 1.3.1 running on Solaris. I have the following servlet called foo.Bar, named FooBar in the web.xml file for my webapp.
    <servlet>
    <servlet-name>FooBar</servlet-name>
    <display-name>FooBar</display-name>
    <description></description>
    <servlet-class>foo.Bar</servlet-class.
    </servlet>
    I can access this servlet from the following url:
    http://localhost/webappname/servlet/FooBar ,
    also:
    http://localhost/webappname/servlet/FooBar/param1/param2
    works as well.
    But, if I put a servlet-mapping in the web.xml file:
    <servlet-mapping>
    <servlet-name>FooBar</servlet-name>
    <url-pattern>/foo</url-pattern>
    </servlet-mapping>
    The following URL does not work:
    http://localhost/webappname/foo/param1/param2.
    Is this a problem in Tomcat? Or is there another section of the web.xml file to tell the url parser to stop at the end of the servlet mapping?
    Thanks.
    C

    This is not a bug. The servlet spec says
    "In the web application deployment descriptor, the following syntax is used to define
    mappings:
    � A string beginning with a �/� character and ending with a �/*� postfix is used
    for path mapping.
    � A string beginning with a �*.� prefix is used as an extension mapping.
    � A string containing only the �/� character indicates the "default" servlet of the
    application. In this case the servlet path is the request URI minus the context
    path and the path info is null.
    � All other strings are used for exact matches only."
    Sounds like you need a pattern of /foo/*

  • Web-inf\web.xml init parameters

    Hi,
    I use several servlets/JSPs which are using common init parameter, is there a way to specify that some init parameters are common or must I write all the parameters for all of my servlets/JPSs ?
    Thanks

    yah that's what I mean, have your parameters in your web.xml file and have a Servlet read them when the application starts up (using ServletConfig). Then you put the values into the application scope where all the JSPs and Servlets can read them. So lets say you specify a parameter called "html-path" with a value of "/www/html/" you could read this in your JSPs like this:
    String htmlPath = application.getAttribute("html-path");I can't remember how to do his off-hand but I know it works.

  • Problem with accessing init parameters from JSP file

    Hi,
    I have my init parameters and Jsp configured in web.xml
    <servlet>
              <servlet-name>TestJsp</servlet-name>
              <jsp-file>/Test.jsp</jsp-file>
              <init-param>
                   <param-name>username</param-name>
                   <param-value>Balboa</param-value>
              </init-param>
    </servlet> How do I access 'username' field from JSP file.
    Kindly help.
    Thanks.

    you can do this in the jsp
    <%=config.getInitParameter("username")%>or do it in the jspInit method in the jsp:
    <%!  String userName = null; 
      public void jspInit() {   
        ServletConfig config = getServletConfig();   
        userName   = config.getInitParameter("userName ");  
    %>
    Hello <%=userName%>

  • How to use init parameters?

    Is it posible to use init parameters with FacesServlet?
    With any other servlet I'd do this:
    <servlet>
    - <init-param>
      <param-name>base</param-name>
      <param-value>/shop</param-value>
      </init-param>
    </servlet>but it doesn't seem correct to the same with the FacesServlet ie:
    <servlet>
      <servlet-name>Faces Servlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    - <init-param>
      <param-name>imageURL</param-name>
      <param-value>/images/</param-value>
      </init-param>What is the right way to use init params with JSF?

    You don't have control over the FacesServlet.
    Rather use the context-param.
    <context-param>
        <param-name>paramName</param-name>
        <param-value>paramValue</param-value>
    </context-param>
    String paramName = facesContext.getExternalContext().getInitParameter("paramName");

Maybe you are looking for

  • Autogenerated sections in printed document

    Hello! I have some problems working with Robohelp 6.0 for Word 1. I want to form Microsoft Word document containing cover page, table of contents, glossary, index etc. I want to form all of these autogenerated sections with my own Word template. I.e.

  • Error 83::8 (not enough memory to initialize PSL) when use layer styles in AEF

    Hello! Have error in AEF CS6 when i try to use layer styles in AEF. Error is  "not enough memory to initialize PSL 83::8" It works good if i start programm as Administrator. My PC is: Windows 7, Intel core 7 with 2.7 Ghz, 6 Gb RAM, Nvidia GeForce 240

  • Nokia Messaging Request for N97

    1. When will Nokia messaging for N97 view HTML? 2. When will Nokia messaging show up an @ sign for new email (which they claim on their website) 3. When can we control to font size when viewing message for N97. But the way i dont think we asking too

  • Reporting on SR Owner Change, Activity Due Date Change

    We have few Report Requirements around Audit Trail. We are looking for Reports where we could Track Service Request Owner change, SR Status Change, Activity Due Date Change etc. As we know, In CRMOD Analytics, we cannot report on Audit Trail or use t

  • Hacking Team 0-Day Shows Widespread Dangers Of All Offense, No Defense

    "The Hacking Team is composed of hackers and security engineers working for the government. They have access to highly confidential data and they likely have a target on their back," says Darren Guccione, CEO of Keeper Security."Despite whether these