views:

454

answers:

8

Consider the following example structure

- Project
    - www
        - files
            + documents
            + html
            + images
            + scripts
    - WEB-INF
        * web.xml

The documents folder needs to be a symlink or in some other way external from the war file because users will add and remove documents (through a mapped network drive).

I'd like to deploy the webapp as a war-file but I don't know how to do that and take the above into account. Could you give some pointers? /Adam

+1  A: 

If it's static content, maybe you'd be better off fronting your app server with a web server and putting the static content there. You relieve the app server of having to serve up static data and save a network roundtrip to boot.

duffymo
A: 

Sounds like you need a web Content Management System (CMS).

duffymo
-1 I don't think that this answer helps the author
Marcel
A: 

Why not store the documents etc. in a database, then have the web-app access the database and allow users to pull files that way? Does it have to be a mapped network drive?

Otherwise if it's a matter of knowing what is there, you could always construct the jnlp file dynamically and pass file lists, etc. in as arguments (if they are server side).

Guess we need to know a little more about what you are trying to accomplish.

I've added a brief explanation below. The location will be shared so a saving the files to database is not an option. Creative thinking though! :)
Adam Asham
+1  A: 

I agree with @duffymo.myopenid.com that fronting your app server with a web server that serves static content for certain URL prefixes is a good, clean solution.

If this isn't feasible in your environment or if you decide that you'd rather handle it in the web application itself, you could write a servlet that effectively does the same thing. For example, create a servlet that is mapped to the URL pattern /documents/*. This servlet could parse the URL (/documents/some/file.png) to determine a relative filename (some/file.png). It could then read and return the corresponding contents found in an external directory (/staticDocs/some/file.png).

dave
A: 

Basically, it's a webapp that aggregates information from various sources and generates documents. It's a requirement that users have the ability to create and upload documents manually from the network without being logged in to the webapp.

Putting the document location path as a context variable is definately doable. I guess it's the easiest way. /Adam

Adam Asham
A: 

Unfortunately, for you .war files are .zip files at heart and .zip files do not support symbolic links. If you are ONLY deploying to a windows machine you may have luck using a shortcut file. However, I'm not sure if the app-server will like that (... probably not.)

I would recommend adding a configuration parameter to the application that allows the document folder's full path to be specified there. The default path should be relative ("./www/files/documents") so that the app works out of the box without additional configuration.

Chris Nava
A: 

Many java web servers support "exploded war files" where you just unzip your .war file into the deployment directory. With tomcat you copy this to $CATALINA_HOME/webapps and you're done.

This should work for you.

Marcel
A: 

What about creating an environment variable on your server that points to the directory the files are stored in? The environment variable may work better than a setting inside your WAR file because you could deploy your application in a new environment (maybe moving from DEV to PROD) without changing your WAR file.

From your java code, you can reference this environment setting with: String docPath= System.getProperty("DOC_PATH");

Michael Debro