I am wrapped around the axel on this one, based on the new 2.1 api.
Basically I want to be able to call servlet B during the
#init(ServletConfig) method of servlet A while it is loading.
Here is what I am doing now (using JRunPro 2.3):
I have a ResourcePool servlet that provides shareable resources like DB
Connections, Threads, etc, to other servlets. When it is loaded (via an
alias) the first time it initializes all this stuff and its resources become
available to others. By using aliases for these resource servlets, many
applications can start their own version of the resource servlet complete
with their own unique configuration requirements.
I have an application controller servlet for each servlet based
'application' running, that will start first. This app servlet is usually
loaded via the preload=true in the servlets.properties. In its #init method
it calls #ServletContext.getServlet(String) for other servlets it needs to
be sure are alive and active to complete its initialization process. The
list of servlets it needs are found in its own configuration file it has
just loaded. In the case of the above ResourcePool Servlet, the app servlet
can now call methods on it to get to the pooled resources.
The nice thing about this is that I can control the startup/access to
resource related servlets in this manner. If a resource servlet is not
already loaded the servlet engine loads it and calls its #init method. Life
is good.
Now, with API 2.1 the RequestDispatcher seems to be the preferred way to get
another servlet. But not really, you don't really get a 'Servlet' handle.
Instead you just seem to get the ability to forward/include request/response
related objects. During the #init phase of my application servlet these
objects do not exist. Also, doing something like:
RequestDispatcher rd =
_myServletContext.getRequestDispatcher("/servlet/"+RES_POOL_CONTAINER_SERVLE
T_ALIAS) works but without throwing Exception but it does not load the
target servlet and cause it to initialize. Also, there is no handle to the
resource servlet that I can use.
Are there any recommended solutions for this situation?
Thanks in advance
========================================
Mike Fontenot - Object Systems Architect
Polygon Network, Inc.
Golden, CO
========================================
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html