-3

When i deploy the war file named 'myapp.war' inside the tomcat 6 webapps folder the images in jsp are loading properly whereas if i deploy it inside webapps/ROOT folder the images are not loading in jsp.

war file structure

-- myapp
- WEB-INF
-jsp
-images

In the jsp page the image inside the images folder are called like

<img src="images/img1.png"/>
Beau Grantham
  • 3,435
  • 5
  • 33
  • 43
Giriraj AR
  • 1
  • 1
  • 1

2 Answers2

1

You should use an absolute path for referencing images. If you include the contextPath in it, the link should work even if your application path changes. Try

<img src="${pageContext.request.contextPath}/images/mobile.png" height="34" width="38" alt="mobile" />
Community
  • 1
  • 1
f_puras
  • 2,521
  • 4
  • 33
  • 38
0

I have found the solution finally.

What happens is when the code is deployed inside ROOT or the war deployed inside webapp and made as ROOT application by changing the context in tomcat server.xml

in either way tomcat is considering like the complete war contents is directly inside the tomcat webapp folder .

I was already having a folder named images directly inside webapps (for some other purpose) because of this the images folder was overridden . when i removed/renamed that folder the expected images (the images called from jsp) started appearing.

Giriraj AR
  • 1
  • 1
  • 1