You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Steve Mysterious <ti...@gmail.com> on 2009/02/03 23:28:43 UTC
Tomcat 6: How to tell a Context/Webapp where to look for files?
Hi;
Tomcat: 6.0
Tomcat Installation Directory: C:\Program Files\Apache Software
Foundation\Tomcat 6.0
OS: Windows XP ( Windows 5.1 service pack 2 )
Java: JDK 1.6.0_10-beta
Context/Webapp Name: abcdev
I'm using the above configuration to set up a development environment for
myself.
I used the very convenient and slick installer for Windows that
automatically sets up a service for me with a useful control interface in my
system tray.
My web application is called "abcdev". I'm setting the "Context" element
for it in a one line file called "abcdev.xml" which I have placed in
c:\Program Files\Apache Software Foundation\Tomcat
6.0\conf\Catalina\localhost\
I noticed that if I don't give my JSPs and my servlet a path that they look
for files in CATALINA_HOME aka my installation directory:
C:\Program Files\Apache Software Foundation\Tomcat 6.0
Can I have my JSPs and servlets look for files in other locations without
altering the code? If so, can I do this on a context (webapp) by context
(webapp) basis?
My apologies if this is in the documentation. I have read the docs, but I
have been away from tomcat for a few years. I'm still catching up on a
learning curve. I'm not used to the jargon yet or the organization of the
docs.
Thanks in advance for any info
Steve
Re: Tomcat 6: How to tell a Context/Webapp where to look for files?
Posted by André Warnier <aw...@ice-sa.com>.
Steve Mysterious wrote:
> Hi;
>
> Tomcat: 6.0
> Tomcat Installation Directory: C:\Program Files\Apache Software
> Foundation\Tomcat 6.0
> OS: Windows XP ( Windows 5.1 service pack 2 )
> Java: JDK 1.6.0_10-beta
> Context/Webapp Name: abcdev
>
> I'm using the above configuration to set up a development environment for
> myself.
>
> I used the very convenient and slick installer for Windows that
> automatically sets up a service for me with a useful control interface in my
> system tray.
>
Hi.
Since you apparently just started with this, may I make a recommendation
that will probably save you a lot of grief later ?
De-install your Tomcat, using the same very convenient installation
package, and re-install it with the same convenient package, but to a
directory without spaces in the names, like C:\Tomcat6.
The Service and so on will work just as well, but this will at the very
least save you a lot of quoting, and at best avoid spending time later
figuring out why this or that doesn't work as you expect.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Tomcat 6: How to tell a Context/Webapp where to look for files?
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Steve Mysterious [mailto:tinker123@gmail.com]
> Subject: Tomcat 6: How to tell a Context/Webapp where to look
> for files?
>
> I noticed that if I don't give my JSPs and my servlet a
> path that they look for files in CATALINA_HOME
You should probably be using ServletContext.getResourceAsStream(), or possibly ClassLoader.getResourceAsStream(). Note that using ServletContext.getRealPath() can be problematic, since the container (Tomcat) is under no obligation to expose the file system (if any) to servlets.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org