tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hugh O'Brien" <hu...@intelis.com>
Subject ServletConfig, ServletContext, and init() methods.
Date Wed, 24 May 2000 20:22:25 GMT
Gang,

I am new to the mailing list ( today ) so forgive my newbie question if
it has already been answered before.

I am running Tomcat as a standalone http webserver and jsp/servlet
engine.

Here is the setup:

   * I have set up a context in my server.xml config file for my web-app
   * I have a web.xml file with only 1 web-app defined in there.
   * Inside that web-app I have serveral context-params
   * We also have a servlet defined in the web.xml file:
     com.intelis.webfe.servlet.MMSetup that loads when Tomcat loads
        o The MMSetup servlet reads the necessary context-param info .
        o Then it gets a reference to a RMI server running on the same
          box.
        o Then thru the RMI servers interface, I get a bunch of object
          references and store those objects as attributes in the
          ServletContext supplied to the MMSetup servlet thru the
          ServletConfig object supplied to the MMSetup objects init(
          ServletConfig ) method by Tomcat.
   * I have deployed servlets in correct the web-apps context  by soft
     linking to my development area
   * There is no problem with Tomcat seeing any the servlets.  I have
     verified this by typing in the url to the servlets.

Here is the problem.  I don't put an entry into the web.xml file for the
deployed servlets.  The servlets are deployed under the
../HTML/WEB-INF/classes/ hierarchy which is the context for this
web-app. These servlets are not supplied the **SAME** ServletConfig
object to their init( ServletConfig ) methods that the MMSetup servlet
was supplied which means I have no access to the ServletContext that
contains the RMI objects that I need ( I have verified that the
ServletContext object is different  from the one that MMSetup got ).

Futhermore, if I put an entry for every servlet we deploy( a deployed
servlet is a servlet that sits in the ../HTML/WEB-INF/classes hierarchy
) in the web.xml file, the servlet's init( ServletConfing) method **IS**
supplied the appropriate ServletConfig object on start up of Tomcat
*******BUT***********the first time you hit that deployed servlet, that
deployed servlet's init( ServletConfig ) method is run
*********AGAIN*********** with a ServletConfig object ( and subsequent
different ServletContext object ) that is different than the one used on
startup of Tomcat for this web-app and I still have no access to my
RMI objects that I need.

This is very confusing.  According to the Java Servlet 2.2 standard,
ServletContext objects are 1 per web-app.  Furthermore,  the init(
ServletConfig ) method should only be run once during the lifecycle of
an instance of a particular servlet.

I would appreciate any help this mailing list could give me.

Thanks in advance !

-- Hugh W. O'Brien
Java Enterprise Developer @ Intelis



Mime
View raw message