• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

image not loading in jsp deployed inside webapps ROOT folder

 
Giri rangaraju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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"/>

I will great if you can suggest some solution
Thanks in advance.
 
RatiKanta pal
Ranch Hand
Posts: 88
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Try

 
Giri rangaraju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It didn't help ..still the images are not loading .When i printed <%=getServletContext().getContextPath()%> its not printing any value.
 
Giri rangaraju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Even i tried setting the Context path to "" but it didn't work

please refer this link http://stackoverflow.com/questions/4044129/tomcat-making-a-project-folder-the-web-root
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for correcting your display name, Giri.

Tomcat doesn't serve loose files, only webapps. And webapps cannot be nested. So dropping a WAR into TOMCAT_HOME/webapps/ROOT will not work, since ROOT is itself an exploded WAR for the webapp at the root context.
 
Giri rangaraju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not deployed the war inside tomcat root folder i have just deployed the contents of the war inside ROOT folder
 
Giri rangaraju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Giri rangaraju wrote:I have not deployed the war inside tomcat root folder i have just deployed the contents of the war inside ROOT folder


I didn't say anything about a "Tomcat root folder". I said that TOMCAT_HOME/webapps/ROOT" is a WAR folder and that you cannot embed WARs within other WARS.

Setting up Tomcat so that the TOMCAT_HOME/webapps folder itself is presented as an exploded WAR is something that you don't want to do.

A) It's not in WAR format, so it won't work reliably.
B) It's a massive security exposure.
C) It's likely to make chopped liver out of the webapps within TOMCAT_HOME/webapps, because - as I said - a WAR cannot contain another WAR.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic