wood burning stoves 2.0*
The moose likes Tomcat and the fly likes how to access other folders outside webapp in tomcat6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "how to access other folders outside webapp in tomcat6" Watch "how to access other folders outside webapp in tomcat6" New topic
Author

how to access other folders outside webapp in tomcat6

Mebi Mathew
Greenhorn

Joined: Jul 19, 2010
Posts: 4
Hi All,

I have recently installed tomcat6 in my windows machine.
Basically I want to access an image file which is located outside tomcat installation directory (C:\files).

I have created a context.xml(C:\Tomcat 6.0\conf\Catalina\localhost\) with the following contents

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/files" reloadable="true" docBase="C:\files" debug="1"/>

I am not able to access the image file after restarting tomcat.

This is how I access the image file --->http://localhost:8085/files/test.JPG
test.jpg file is located in C:\files folder

I am getting tomcat home page by typing http://localhost:8085

Is there anything I should configure

Can anyone please help me to resolve this issue

Jesus Mireles
Ranch Hand

Joined: Mar 10, 2010
Posts: 122

do you get a different result if you set the attribute crossContext="true"
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Lucas Mireles wrote:do you get a different result if you set the attribute crossContext="true"

That will do nothing.

Use the Tomcat Manager app to see if your web application is even running.
Mebi Mathew
Greenhorn

Joined: Jul 19, 2010
Posts: 4
Hi

Thanks for the quick response

My application is running

If i am wrong can you please guide me how to access the image file which is located outside tomcat installation directory.

Should I put specify it in the server.xml file ?

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

If the app is running and the image file is in the folder hierarchy of the app context, the image file is addressable. You'll need to give us more details of how you set things up and what's going wrong.
Mebi Mathew
Greenhorn

Joined: Jul 19, 2010
Posts: 4
Hi

I have an application where I need to access image files which is located outside tomcat installation directory

For example an image file is located on C:\files\test.jpg

When I tried to access the image file directly(http://localhost:8085/files/test.jpg),I am getting HTTP Status 404.

Can you guide me what I have to configure to access the image file

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Mebi Mathew wrote:I have an application where I need to access image files which is located outside tomcat installation directory

The Tomcat installation folder is moot. All that matters is where the web app context is established.

For example an image file is located on C:\files\test.jpg
When I tried to access the image file directly(http://localhost:8085/files/test.jpg),I am getting HTTP Status 404.


Is files the context path of the web app context? Does the Manager App show the app running at this context path?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

No, no, no, no, no. A web server is not a file server!

What you've actually done is tell Tomcat that your entire webapp is located in the C:\files directory. That is, your exploded WAR is C:\files and the context that you deployed to Tomcat under was "/files".

Because the default action for ".jpg" resources in Tomcat is to retrieve them, the URL http://localhost:8085/files/test.jpg should, in fact display the contents of C:\files\test.jpg in your browser window.

Subject to the following limitations:

1. You have configures Tomcat to respond to http requests on port 8085. The default http port is 8080.

2. The Tomcat server process has read-access rights to file C:\files\test.jpg.

Getting a "404" error generally indicates that you've made condition #1 happy, so I'd check the users and groups settings on the test.jpg file and on the C:\files directory against the user/group configuration that Tomcat's running under.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
 
subject: how to access other folders outside webapp in tomcat6
 
Similar Threads
Using External style sheet to include background image in JSP
http://localhost:8085 is giving page not found error when Tomcat is running
problem running the HelloWorld ! servlet
Tomcat set up
servlets contents not being updated