Exactly. Since we are supposed to write an application that's running without extracting the war, Steves approach was my first try, but it's not working that way :(
Also, symlinks are a good way in posix systems, but then the app is not platform independent anymore. The approach of a reader servlet sounds good, but how can I implement this to include the files into a jsp then? In other words, if "/App/Reader" is my reader servlet, can I include an image into jsp with <img src="/App/Reader?file=image.jpg" />? 2008/12/14 Yuval Perlov <yu...@r-u-on.com> > The problem with this approach is that when you upgrade the war file the > files will be deleted. > I believe It is better to save the files outside the web app and deliver > them either with a symbolic link from within your war file or using a reader > servlet. > > Yuval Perlov > www.r-u-on.com > > > > On Dec 14, 2008, at 7:17 PM, Steve Ochani wrote: > > Send reply to: Tomcat Users List <users@tomcat.apache.org> >> Date sent: Sun, 14 Dec 2008 12:56:17 +0100 >> From: Robert Drescher <robert.dresc...@gmail.com> >> To: users@tomcat.apache.org >> Subject: File system resource for static content >> >> Hello users, >>> I'm trying to find the best practice way for implementing the >>> following: I want a servlet to perform file uploads and to store the >>> files in the local filesystem. This part is not that hard to do as i'm >>> currently writing into the javax.servlet.context.tempdir. >>> >>> The problem is that i need to store the files in a directory, that >>> will be accessible from the web. My tutor at university gave me the >>> hint that this is best done with a resource which points to a local >>> directory and that's mapped to the webapp. >>> >>> So I imagine that http://localhost:8080/WebTest/Upload is my servlet >>> mapping and that http://localhost:8080/WebTest/files/ points to this >>> resource. >>> >>> >> I do something very similar using apache commons upload project. >> >> I have a separate files directory in my webapp directory and I use the >> following code to >> initialize a path to save my uploaded files: >> >> ServletContext sc = getServletContext(); >> String path = sc.getRealPath("/files"); >> >> I can then access a file in the that files directory via >> >> http://server:8080/appname/files/filename >> >> >> -Steve O. >> >> >> >> >> But all my research in the documentation did not bring any success. I >>> know that i can specify resources in the context.xml, but not how I >>> specify the path on the local system or how to do the mapping... If >>> anyone already did this and can provide me with configuration >>> examples, I'd very much appreciate it. >>> >>> I am using Tomcat 5.5 on Linux (not the pre-packaged), the application >>> is deployed as war, my context.xml is located in META-INF >>> ------------------------------------------------------------ <?xml >>> version="1.0" encoding="UTF-8"?> <Context privileged="true" >>> antiResourceLocking="false" >>> antiJARLocking="false" >>> path="WebTest" >>> /> >>> ------------------------------------------------------------- >>> >>> My web.xml is the following: >>> ------------------------------------------------------------- >>> <?xml version="1.0" encoding="UTF-8"?> >>> <web-app version="2.4" >>> xmlns="http://java.sun.com/xml/ns/j2ee" >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee >>> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> >>> <description>Test Internetapplikationen</description> >>> >>> <servlet> >>> <description>Controller Servlet</description> >>> <display-name>Controller Servlet</display-name> >>> <servlet-name>Controller</servlet-name> >>> <servlet-class>org.agility.webtest.control.Controller</servlet-cla >>> ss> >>> </servlet> >>> >>> <servlet-mapping> >>> <servlet-name>Controller</servlet-name> >>> <url-pattern>/Controller</url-pattern> >>> </servlet-mapping> >>> <welcome-file-list> >>> <welcome-file>Login.jsp</welcome-file> >>> </welcome-file-list> >>> </web-app> >>> ------------------------------------------------------------------ >>> >>> Thank you very much for your help >>> Robert >>> >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: users-h...@tomcat.apache.org >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >