File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes image not loading in jsp deployed inside webapps ROOT folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "image not loading in jsp deployed inside webapps ROOT folder" Watch "image not loading in jsp deployed inside webapps ROOT folder" New topic
Author

image not loading in jsp deployed inside webapps ROOT folder

Giri rangaraju
Greenhorn

Joined: Feb 19, 2009
Posts: 7
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

Joined: Nov 13, 2011
Posts: 64

Hi,

Try

Giri rangaraju
Greenhorn

Joined: Feb 19, 2009
Posts: 7
It didn't help ..still the images are not loading .When i printed <%=getServletContext().getContextPath()%> its not printing any value.
Giri rangaraju
Greenhorn

Joined: Feb 19, 2009
Posts: 7

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

Joined: Jun 25, 2001
Posts: 16160
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Giri rangaraju
Greenhorn

Joined: Feb 19, 2009
Posts: 7
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

Joined: Feb 19, 2009
Posts: 7
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

Joined: Jun 25, 2001
Posts: 16160
    
  21

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.
 
 
subject: image not loading in jsp deployed inside webapps ROOT folder