0

I have a Java webapp (RESTEasy) organized as follows:

src/main
  |- java/
  |- webapp/
    |- WEB-INF/
      |- web.xml
    |- public/
      |- <compiled static files>

The public folder gets filled with static files (index.html, compiled js, css and resources) by my build chain. When building the WAR archive, I can access the static files under /public/index.html.

Is there a way to serve my static files directly from the root (/index.html)? I know that I can directly put them in my webapp folder, however due to my build chain and project structure, I would like to avoid this.

3
  • Is this Spring? Commented Apr 5, 2017 at 15:25
  • No, RESTEasy. But the setup should be similar to most Java servlets. Commented Apr 5, 2017 at 15:35
  • Can you have your build chain move them to the root in the WAR file? It is pretty easy to do this with ANT. Commented Apr 5, 2017 at 18:33

1 Answer 1

1

Normally, containers allow you to specify the document root. It means you can have the web application like structure where ever you want. But, you cannot have something like what you want. Since, it is not Web application structure.

Some containers also allow you to specify the documents base. Like Tomcat for Ex,You can specify this in the server.xml

<Context docBase="/path/to/files" path="/files" />

One workaround is adding a filter that will prepend "public" to all the urls.

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.