Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

tomcat - access files outside of webapp

Thread view: 
j - 29 Jan 2008 02:43 GMT
I've written a little photo album servlet.  Images can be uploaded and
they are saved to some external directory: /some/dir/photos.

I'd like to be able to access these photos using <img> tags, but don't
know how to access anything outside of the external directory.  On the
other hand I don't want to save the images inside the webapps
directory as the photos will all be lost every time I redeploy the
app.

I've created a static dispatcher servlet to access the images, but
it's slower and seems to break browser caching.  Thus I'd prefer to
just use <img src="..."> tags if possible.

Can anyone point me in the right direction here?

Thanks,
J
Arne Vajhøj - 29 Jan 2008 02:48 GMT
> I've written a little photo album servlet.  Images can be uploaded and
> they are saved to some external directory: /some/dir/photos.
[quoted text clipped - 8 lines]
> it's slower and seems to break browser caching.  Thus I'd prefer to
> just use <img src="..."> tags if possible.

If you use a servlet to serve them, then you get access control - direct
download and you have no control.

But if you want to go that route, then you need to get that image
directory served.

Either by Apache outside of Tomcat or by Tomcat. I believe that
you will need to add a new context to Tomcat to have Tomcat serve
them.

Arne
j - 29 Jan 2008 04:09 GMT
> > I've written a little photo album servlet.  Images can be uploaded and
> > they are saved to some external directory: /some/dir/photos.
[quoted text clipped - 20 lines]
>
> Arne

Thanks much for providing some direction.  After a little digging and
trial-and-error, I was able to add the directory as a context and can
now use <img> tags they way I wanted.
umacts@gmail.com - 14 Mar 2008 21:48 GMT
> > > I've written a little photo album servlet.  Images can be uploaded and
> > > they are saved to some external directory: /some/dir/photos.
[quoted text clipped - 26 lines]
>
> - Show quoted text -

Hi,
I have the same problem. Can you please explain what you did and how
you added a new context path?

Thanks
Uma
Gilbert Rebhan - 14 Mar 2008 22:09 GMT
/*
> I have the same problem. Can you please explain what you did and how
> you added a new context path?
>
> Thanks
> Uma
*/

You have to create a context in the
%TOMCAT_HOME%/conf/web.xml, see=
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

Regards, Gilbert


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.