1

My Java web application needs to serve up many static HTML reports.

The reports are generated on-demand using a 3rd party application based on user's inputs. The reports will always be different from run to run, so they can't be cached. The reports include multiple HTML pages (including JS and CSS pages), and relative links between files.

What's the easiest way to serve up these reports to the front-end user?

The reports don't need to stick around -- they can be deleted after a set time or after the user logs out.

I'm using:

  • Tomcat 7
  • Spring framework

Here is a similar example:

Suppose the web app is an online IDE, and you'd like to occasionally generate and display Javadoc pages for the project.

3
  • 1
    i think try to copy your static resource into apache2 it should work for you Commented Jun 20, 2014 at 12:57
  • this is far too broad, and not clear Commented Jun 20, 2014 at 13:01
  • @NimChimpsky What's not clear? The Java web app received some arbitrary static HTML files. How can it serve them up to the front-end user? Commented Jun 20, 2014 at 13:27

1 Answer 1

1

I would personally use a web server, such as Apache, to do this, since my Java applications are always behind Apache. Here is an Apache example:

# Serve /path/to/html/files/ with static files stored at /var/path/to/files/
ProxyPass /path/to/html/files/ !
Alias /path/to/html/files/ /var/path/to/files/

# Proxy / to Java application at localhost:8080
ProxyPass / http://localhost:8080/

If you must use a pure Java solution, you could try to set up a file download servlet, such as this one by BalusC. Just be careful about handling file paths supplied in request urls, as the servlet can be vulnerable to directory traversal attack.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.