tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: WebApps sharing uploaded files
Date Fri, 30 Sep 2011 20:47:40 GMT
Léa Massiot wrote:
> Hello,
> 
> Thank you for reading my post.
> 
> o I have two WebApps "w1" and "w2" (under the Tomcat "webapps" directory).
> o Both "w1" and "w2" contain (at least) a JSP which allows to upload files
> to the server.
> o Presently, the uploaded files are stored:
> - in the "w1\uf1\" directory for "w1",
> - in the "w2\uf2\" directory for "w2".
> (So: each WebApp has its own directory for uploaded files storage).
> => I need the two Webapps to store their uploaded files in the same
> directory, say "uf".
> 
> Let's say that: 
> - we have created "uf" somewhere (where?),

You can define "uf" wherever you want, as long as Tomcat (and the applications which run 
under it, like your JSPs) has write access to it.

> - "uf" contains a successfully uploaded file "f.txt",
> - I have a JSP "foo_1.jsp" in "w1" and a JSP "foo_2.jsp" in "w2".
> 
> I'd like:
> - to put an anchor in "foo_1.jsp" which links to "f.txt".
> ----------------------------------------------------------------------
> < a href="?_1/f.txt">Link 1</ a>
> ----------------------------------------------------------------------
> - to put an anchor in "foo_2.jsp" which links to "f.txt".
> ----------------------------------------------------------------------
> < a href="?_2/f.txt">Link 2</ a>
> ----------------------------------------------------------------------
> (I want the files to open properly when the each link is clicked).

Then you should probably create another JSP/servlet, whose role is to download the 
requested file to the browser, and which is called with the file name as an query 
parameter.  It can then read the file wherever "uf" is, and return it to the browser.

Now unless this is a purely academic project to learn about webservers and/or Tomcat, the

whole thing sounds a bit over-simple, and does not take into account a lot of dangerous 
aspects of this kind of application.

And if it is not purely an academic project, I would recommend having a look at the WebDAV

application, which may be what you are looking for.

I wish I could give you a pointer to some documentation about that application, but I 
can't seem to be able to locate it on the Tomcat website.


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


Mime
View raw message