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.

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-class>
  </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

Reply via email to