I'm building a servlet that uses a RequestDispatcher to load a html page for the log in.
The html is in /WEB-INF/templates/main.html
I'm trying to load an image for that html file which is on /WEB-INF/resources/image.jpg
I've tried with <img src="/WEB-INF/resources/image.jpg
, and also without the slash before WEB-INF.
I tried with <img src="../resources/image.jpg
as well.
None seems to work, how can I do this?
You can't do this.
The problem is that the image is being loaded by the browser, not the application. And nothing outside the internals of the application can access anything in the WEB-INF
directory.
So, you simply need to move the image someplace else.