"Emuleomo, Olu (PME)" wrote:

>         >>>>>>
>         As an alternative to singleton classes, you might also consider
> storing these
>         objects in the ServletContext via the setAttribute() method.  Such
> objects are
>         always available to your servlet via:
>
>             getServletContext().getAttribute("KEY");
>
>         and, as an extra benefit, you can run more than one application on
> the same
>         server if you need to (each in its own ServletContext), without
> running into
>         name clashes on your Singleton classes.
>         <<<<<
>
>         Craig,
>
>         When you say "you can run more than one application on the same
>         server if you need to (each in its own ServletContext),", I assume
> you mean
>         that you can run the applications in different PROCESSES on the same
> MACHINE.
>         If not, how do you get more than one ServletContext in the same JVM?
>

The precise details depend on your servlet engine, but I would expect most
(all?) engines that support the 2.1 spec to let you run multiple apps (in
separate contexts) in the same JVM.  Some will let you use multiple JVMs if you
want.

It is up to the servlet engine (and/or the web server it runs in) to look at
the request URI on the incoming request and "assign" it to the correct servlet
context, which will then select the correct servlet to run based on either
matching the rest of the path or matching the filename extension (such as
sending all ".jsp" files to the JSP servlet).

As an example, look at the way the JSWDK servlet engine is configured.  It
comes predefined with two different contexts (i.e. two different applications)
in the included config files:

* The "examples" context that gets used for all
  requests that start with "/examples".  The document
  root for this is $JSWDK_HOME/examples.

* The default context that gets used for all other
  requests.  The document root for this context is
  $JSWDK_HOME/webpages.

Both of these contexts run happily in a single JVM.

>
>         --Olu E.
>
>

Craig

___________________________________________________________________________
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

Reply via email to