TAGS :Viewed: 4 - Published at: a few seconds ago

[ unable to access or navigate the image file in jsp code ]

I am unable to navigate to image file in my jsp code. Both .jsp and image files are in different directories. I want to use image in my header.jsp file. Below is the snapshot. Guide me.

enter image description here

As you can see, my header.jsp file is under WebContent > WEB-ING > views folder. I am unable to load the image in this jsp. Also, as it is seen pic.png file is under resources > images. How can I load that image in my Header.jsp using <img src=""> tag. Guide me.

Answer 1

if you use spring you should specify the directory with resources

<mvc:resources mapping="/resources/**" location="/resources/" />

you project should look like this

   - src(java sources)
   - resources(images, css, js etc.)
   - webapp(here is web-inf, meta-inf etc.)

Answer 2

I think you are using eclipse. so try using this path:

/YOUR PROJECT NAME/resources/images/pic.png