How to bind a Directory as URL
hi there,
i'm currently working on some upload mechanisms and have a small idea to fulfill.
I need to bind a filesystem directory (any pointed out in configuration - a uploaded files storage) as a URL under tomcat, e.g. having the dir "/home/upload" i'd like to bind in under e.g. "/myapp/uploadBucket" directory of already existing "/myapp" web application in Tomcat 5.5
how to do it in an easy way? i know it's fairly easy to bind a dir as an additional context but i need the session configuration to be handled in one webapp - so i need to have the url inside /myapp webapp
..any hints appreciated
rafal zaczynski
http://baton.pop.e-wro.pl
# 1
if you create a directory under your web application directory structure in tomcat, you will be able to access with a URL. Let's say the application is called myApp and you want to create a home folder directly under it, you can just say http://localhost:8080/myApp/home
# 2
hi there,
the stuff u'r saying is of course true - but obvious. the situation i'm interested in is kinda different - i need to bind another filesystem directory (not existing under webapp root in filesystem) under a predefined suburl of webapp
eg. lets assume that webapp root dir is "/home/web" and it has some physical subdir named "sub" so of course its accessible using http://host/webapp/sub/
but how to bind eg dir "usr/temp/upload" under url "http://host/webapp/uploadBasket" and still have the rest of dirs normally..
solution would be write a servlet that simply rewrites contents of files from "usr/temp/upload" dir and bind it inside web.xml file using "/uploadBasket/*" prefix - but maybe there would be some solution of having it done using some tomcat default servlets etc? or some existing servlet libs? or..?
rafal zaczynski