On Wed, 23 Oct 2002, Bryan Dollery wrote:

> Date: Wed, 23 Oct 2002 16:55:40 +1300
> From: Bryan Dollery <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> Subject: Manager?
>
> Hi,
>
> Tomcat 4.1.12 question:
>
> 1. Install and Deploy manager functions - what's the difference?
>
> The documents mention something about deploy copying and install not doing
> so, but I can't find any more information on this. I've looked back through
> this list's archives and can't find any other mention of the difference.
>

Install "mounts" a WAR file or directory right where it currently sits,
with no copying.  In effect, it dynamically creates a <Context> element
that has an absolute path for the "docBase" attribute.  Because of this,
the WAR or directory must exist on the server that is running Tomcat.
Because no copying occurs, this can happen pretty quickly.

Deploy uploads a WAR file to a private location within the Tomcat
directory hierarchy, and runs the webapp directly from there.  Because of
this, you can deploy to a Tomcat running on a different server than where
you are.  NOTE - The deploy command uses an HTTP "PUT" transaction, so
it's not usable directly from a browser.  The easiest way to use it, then,
is to utilize the custom Ant task that is provided.

The deploy mechanism is designed for easy integration into tools.  For
example, the "deploytool" GUI in the Java Web Services Developer Pack uses
the deploy function behind the scenes for you.

> 2. How does tomcat handle manager deployed files?
>

Note that, in a properly designed webapp, you should not have to care
about this.  But let's answer the questions for curiousity's sake.

> If I deploy (manager deploy) a simple war file, with a single html page
> linking to a simple hello-world servlet it works fine. But, I don't know
> what tomcat is doing with the contents of the war.
>
> I can see that the war itself is copied to the manager work directory, and
> that the class files are unpacked. However, the html file, and the web.xml
> file don't get unpacked. Does tomcat access these directly from the war,
> and if so does it cache them?
>

Tomcat is perfectly happy to run an application directly from a WAR file
if you want to.  The classes and JARs have to be copied so that they are
accessible to the Java compiler utilized to convert your JSP pages into
servlets.  All the other resources are accessed directly from the WAR.

Note that exactly the same thing happens to a WAR file that you put in the
webapps directory, if you turn the unpackWARs option off.

One ramification of running directly from a WAR file *is* visible to your
webapps - the ServletContext.getRealPath() method will always return null,
because there is no such thing as a "real path" to a resource embedded in
a WAR.  To avoid any difficulty caused by this, you should always program
using ServletContext.getResource() and ServletContext.getResourceAsStream()
if you need access to resources in the WAR.  These calls are guaranteed to
work portably on all servlet containers -- running from unpacked directories
the way Tomcat does is a Tomcat specific feature, and is *not* defined in
the servlet specification.

> Thanks for any answers you can provide.
>
> Cheers,
>
> Bryan

Craig


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>

Reply via email to