• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

how to access other folders outside webapp in tomcat6

 
Mebi Mathew
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 122
Mac IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do you get a different result if you set the attribute crossContext="true"
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 28753
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic