This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 62

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: 15951
    
  19

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: 15951
    
  19

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: image not loading in jsp deployed inside webapps ROOT folder
 
Similar Threads
java html show img src is system path
Problem running Struts applications on external Tomcat server
Using External style sheet to include background image in JSP
Help with JBoss 3.2.3
new to servlets