What URL do you use to access your web application?
What is the URL that the broken image is using to look up the image? (You can find out using the Browser F12 developer tools, or just viewing source on the generated page)
What URL should it be using? Can you fiddle around with the URL manually to load the image successfully?
Couple of things I think might be contributing here:
You say your image is at: MyProject/resources/images/stockmarket.jpg
But then you try and reference it with: /resources/stockmarket.jpg
What happened to "MyProject" ?
What happened to "/images" ?
The image is using an absolute URI - it starts with "/", so will look for the picture from the root of the webserver.
Most probably your URL needs to include the
servlet context value
However most probably, the correct url to be looking is at "/MyProject/resources
The context root for a web application is dynamic (normally based on the name of the war file)
The standard way of doing this is to
- Include an expression in the image url to the servlet context into the URL
- use a JSP/JSTL tag to convert a url for you (looks slightly tidier)
i.e.:
or