Ankur
Ankur

Reputation: 51110

Deliver files from a web server from outside the web app

Is there anyway to serve a file from a web server through the web, that is not within the web application.

I am using Tomcat and a Java servlets based application.

I don't want to put the files within the webapp because they are several 100GB and I will have to replace them every time I update the WAR if I put them inside it.

Upvotes: 0

Views: 193

Answers (2)

Simon Massey
Simon Massey

Reputation: 31

You can simply map a URL to a servlet and the servlet can open the file from anywhere and read bytes from the fileinputsream and write them to the response output stream. You should add browser cache headers and also compress the data as you write it to the browser see http://onjava.com/pub/a/onjava/2003/11/19/filters.html

Upvotes: 1

Boris Pavlović
Boris Pavlović

Reputation: 64632

Apache web server can serve static files and delegate dynamic content requests to Tomcat.

Upvotes: 1

Related Questions