Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Images not displying on jsp inside the folder

 
Roshan Wankhade
Greenhorn
Posts: 21
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Roshan Wankhade
Greenhorn
Posts: 21
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the Reply...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic