aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Images not displying on jsp inside the folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Images not displying on jsp inside the folder" Watch "Images not displying on jsp inside the folder" New topic
Author

Images not displying on jsp inside the folder

Roshan Wankhade
Greenhorn

Joined: Dec 07, 2011
Posts: 21

Hi Friends,
I'm new to web application development.
I'm doing web based project in eclipse.... Displaying the images on jsp page.
My directory Structure in eclipse...

-webContent
--css
--img
---images
----logo.png
--jsp
---login
----login.jsp
--META-INF
---MANIFEST.MF
--WEB-INF
---lib
---web.xml

When my jsp pages is in WebContent directory then images display on the page... <div id="logo"><img src="img/images/logo.png"></div>

But when i created the different directory for the jsp pages inside WebContent Directory and store my jsp pages inside it then the images are gone...

i think its problem for path of images... but can't figure out...
Please help me friends...
Thanks.
D. Ogranos
Ranch Hand

Joined: Feb 02, 2009
Posts: 214
Maybe you didn't update your build script, so it still copies the images directly to webContent. Try to enter the original path (should look something like http://myserver/mywebapp/logo.png) as an URL in your browser, and see if the images show up? Then try the same with your new path.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

Image references are always relative to the location of the JSP that generated the HTML. So if the JSP is in webcontent, then an will find images in webcontent/img, but if you move the JSP to a subdirectory, then you need to switch the image reference to .


JBoss In Action
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61193
    
  66

Image URLs, along with all other resource URLs in a JSP should be server-relative URLs that begin with the context path. See the JspFaq for more details.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Roshan Wankhade
Greenhorn

Joined: Dec 07, 2011
Posts: 21

Peter Johnson wrote:Image references are always relative to the location of the JSP that generated the HTML. So if the JSP is in webcontent, then an will find images in webcontent/img, but if you move the JSP to a subdirectory, then you need to switch the image reference to .


It's working... Thanks Peter.
Can you please tell me how can i get the root path for my WebContain directory.
I'm doing project using struts 2 and hibernate 3.6.
Thanks again.
Roshan Wankhade
Greenhorn

Joined: Dec 07, 2011
Posts: 21

Thanks for the Reply...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Images not displying on jsp inside the folder