0

I have a simple servlet which is supposed to fetch a HTML from my project and display it using servlets. The HTML is displaying fine, but the image is not being recognized and returning a 404.

Here is the snippet from the HTML which is giving me a 404:

<a href="index.html"><img src="WEB-INF/images/logo.png" alt=""/></a>

Error:
Request URL:http://localhost:8080/JPA/images/logo.png
Request Method:GET
Status Code:404 Not Found

Here is my servlet code (Landingpage.java):

request.getRequestDispatcher("WEB-INF/index.html").include(request, response);

The project's name is JPA, and the HTML + image is under WEB-INF. The image specifically is under a folder called "image" as you can see on the screenshot.

Here is a screenshot of my project setup.

All help is appreciated. Thank you.

Rao
  • 20,781
  • 11
  • 57
  • 77
  • `request.getRequestDispatcher("index.html").include(request, response);` – Suresh Atta May 07 '16 at 20:28
  • See [this answer](http://stackoverflow.com/a/5473961/1458740) – Ilya May 07 '16 at 20:40
  • I think your problem is that you have put your images under `WEB-INF` directory. The resources in this directory cannot be accessible for public. So you have to move the `images` directory in the root of your web project, i.e. in the same level as `WEB-INF`. – ujulu May 07 '16 at 20:42

0 Answers0