I have Static Web project in Eclipse and using Http Preview server for development. I want to use root relative path in my resources (e.g. /css/style.css
) but I can't figure out how to configure that server to work. There always needs to be context root in path (e.g. http://localhost:8080/myapp). Context root can't be configured as empty. Is there any option I'm missing?

- 12,170
- 10
- 58
- 70
1 Answers
I have found a workaround for this problem if you are working on a Unix variant. It relies on symbolic links, so it probably cannot be made to work on Windows. I claim no points for elegance, but it does seem to work for me on Ubuntu.
First, you create a new static web project in Eclipse that will contain a link to the resource directory. In this case, you can call the project css
. Alternatively, give it a descriptive name, and change the context root to css
using the project properties dialog.
In a terminal window, change to the project directory for the newly created project. Probably something like ~/workspace/css/
. Then replace the WebContent
directory with an appropriate symlink:
cd ~/workspace/css
rmdir WebContent
ln -s ../myproject/WebContent/css WebContent
Now return to Eclipse and refresh the css
project. You should now see all of your css files in the project explorer.
Run the css
project and the original project on the HTTP preview server.
You will have to repeat this process for each of the top-level resource directories.

- 6,667
- 1
- 33
- 35