You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Moises Lejter <ml...@teamsoftinc.com> on 2006/08/02 20:19:31 UTC

WAR deployments and uploaded files...

Imagine that you wanted to allow the user to upload files to your web
app, that you then wanted to save - say for example web pages that you
wanted them to upload to your web app to display...

 

My first thought was, my web app can only write to /WEB-INF, so I should
put these files there.  Which I can do - but the inside of /WEB-INF is
not visible to the web browser, so I also need a servlet that will read
these files out of /WEB-INF to send to the browser, as appropriate.
Cumbersome.  So my second thought was, tomcat will let me write
elsewhere inside my web app, so I should just create a folder inside my
web app's doc root, and just put these files there.  Browsers will just
access these files by name, inside their folder, like they access every
other page on my web app.  Ok - though I am not sure I am supposed to
write inside my web app, but outside /WEB-INF...

 

However - I am deploying my web app using a WAR file.  So, I cannot
assume I can write anywhere, if I am deploying out of a WAR - unless the
web server expands the WAR on deploy.  So I set up tomcat to do that...
Only to discover that when the WAR file is updated, tomcat will remove
the existing expanded WAR file, in order to redeploy the application -
and incidentally removing all those pages my users so carefully
uploaded... L

 

The third thing that occurs to me is just to put the files somewhere
outside the web app... But then users could not get to them, unless I
write a servlet to go get them for the user, and send them back (as in
my first idea above).  This strikes me as non-portable...

 

So... The fourth thing that occurred to me was to save the pages in a
database, then write a servlet to retrieve them from the database to
deliver to the user ... Which seems like too much work...

 

Is there a best practice I should be considering here?

Thank  you!

Moises

 

 

 

Moises Lejter

 

Phone: 608-827-7772 

Email: mlejter@teamsoftinc.com

 


Re: WAR deployments and uploaded files...

Posted by Mark Thomas <ma...@apache.org>.
Moises Lejter wrote:
> Is there a best practice I should be considering here?

How about this for a quick and dirty approach.

Use two contexts. One for your app and one, with webDAV enabled, for
any uploaded content. That way, any application updates won't change
the content.

Mark

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org