4 Replies Latest reply on Aug 21, 2003 2:18 AM by Steve Ahlstrom

    DOCROOT

    Steve Ahlstrom Newbie

      This is more of a Tomcat question than JBoss, but I'm hoping that I can find a answer here ...

      I've deployed a webapp. One of the features of the app is the ability to upload pictures. I'm saving the pics to the file system. This works fine.

      My problem is when I want to display the picutures that were uploaded. It appears my webapp can't see beyond it's own war (docroot).

      How can I configure an additional docroot or otherwise have my webapp able to access the file system where the pictures were stored? I guess I could always store them in the database as blobs but I really don't want to do that.

      Thanks

        • 1. Re: DOCROOT
          Jon Barnett Master

          You can configure an additional empty WAR directory in deploy - say uploads.war. Anything you place in there will be accessed as http://localhost:8080/uploads/*. This assumes that your existing web applications have not already reserved the URL.

          Pass to the servlet that saves the file an initparam that specifies the absolute directory location for the upload storage. Obviously you can programmatically hard code it, but having an initparam in the deployment descriptor allows the deployment engineer to deal with it, not the programmer.

          Save the file, dealing with the appropriate things problems such as multiple users and so on - use the passed parameter to target the save location.

          Hope that makes sense.

          • 2. Re: DOCROOT
            Steve Ahlstrom Newbie

            Thanks ... I'll give that a try.

            Wouldn't it be a bit more conventional to get JBoss/Tomcat working with Apache then just dump the files in docroot?

            That's what I'm trying to figure out now -- reading TONS of messages here from people trying the same ... so much material but no real cookbook on how to do it successfully.

            • 3. Re: DOCROOT
              Jon Barnett Master

              You can dump it in the Apache docroot if you are using Apache as a front-end. However, in most cases, the front-end is usually not on the same hardware so this becomes problematic as a general solution.

              For your case where everything is on the same boxen, you can write directly to the Apache docroot directory or a subdirectory, thereof. The same technique applies. Just ensure that permissions for writing are adequate.

              • 4. Re: DOCROOT
                Steve Ahlstrom Newbie

                BTW, this works great. I can serve static content without the need for Apache. Thanks. I'd never have thought of faking a war as a directory ... the only thing I really needed to do was to add a WEB-INF directory with a jboss-web.xml .