• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Images not displaying using JSF?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,
I'm not a java programmer, I'm just an administrator for some WebSphere servers, so I'm hoping someone here can help me out.

This guy developped a Java Application which has the context-root of /SomeApp. This is the first application we are deploying using a Java Server Faces implementation. In main JSP's he includes a couple other JSP's like such:

<jsp:include page="header.jsp" />

In this included JSP, he has html code such as:

<img src="images/appimage.jpg">

Well, now what's happening is when the page loads, it's looking for the image using the following URI:

/context-root/faces/images/appimage.jpg

such as:

/SomeApp/faces/images/appimage.jpg

The question is, why is it inserting "faces" into the URI? This developer claims it's a configuration issue on WebSphere and claims there's NOTHING he can do about it. He also says it works fine on his laptop, but he has fileServing enabled there, so obviously it would work.

The reason that this is an issue is that we run all of our applications with fileServing disabled, so the images, style sheets, etc, all get served up by Apache and not Websphere. In the past we've simply included Alias's in the httpd.conf for the context-root/images to point to the correct location on the filesystem, however, with this faces implementation, it apparently defaults in the web.xml so that all of context-root/faces/* goes to Websphere.

Any help on this is greatly appreciated.

Thanks!
 
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I too use websphere, my images path are like "/images/individual.gif" in the h:graphicImage and it works perfectly for me.

I am bit confused over whether you are using JSF image component for displaying images or an html tag?
 
Joseph Henstay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Varun,
Thanks for the reply. I've been looking at this developers code and it looks like the main page that he is displaying is using the JSF markup like you show there, however, in that page, he has that <jsp:include page="header.jsp" /> line, but in header.jsp, he is NOT using any of the JSF markup code, it looks like he is using straight HTML in there. Is that the problem? Should he be using the JSF markup code instead of a regular HTML image tag in the included JSP?

Thanks again!
 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
using a / before makes the location of the images file relative to the context root. For example /images/whatever.gif will actually be read as
/context-root/images/whatever.gif. When not using the /, you are specifying that the images directory is relative to the current directory that the calling jsp is located in. For example, if you call images/whatever.gif from the whatever.jsp located in the /context-root/faces directory the call to images/whatever.gif is actually a call to /context-root/faces/images/whatever.gif.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Joseph Henstay:
Varun,
Thanks for the reply. I've been looking at this developers code and it looks like the main page that he is displaying is using the JSF markup like you show there, however, in that page, he has that <jsp:include page="header.jsp" /> line, but in header.jsp, he is NOT using any of the JSF markup code, it looks like he is using straight HTML in there. Is that the problem? Should he be using the JSF markup code instead of a regular HTML image tag in the included JSP?

Thanks again!



I feel that your header.jsp has not even a single JSF component, is that the case?
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by William Duncan:
using a / before makes the location of the images file relative to the context root. For example /images/whatever.gif will actually be read as
/context-root/images/whatever.gif. When not using the /, you are specifying that the images directory is relative to the current directory that the calling jsp is located in. For example, if you call images/whatever.gif from the whatever.jsp located in the /context-root/faces directory the call to images/whatever.gif is actually a call to /context-root/faces/images/whatever.gif.



Your point in right, but in JSF worlds when you say /ctx-root/faces/images .. it normally means your directory strcture is /ctx-root/images

the /faces is used to tell conainer that this request should be handled by FacesServlet [by configering the servlet-mapping/url-pattern in web.xml file].
 
Joseph Henstay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Varun,
Yes, you are correct that it looks like header.jsp does not have any JSF in it at all.

Ok, then my question is, how come when we access the main.jsp page, which has JSF in it and includes header.jsp, which doesn't have any JSF code in it (other than listing the taglibs in the <HEAD> and header.jsp has the line:

<img src="images/appimage.jpg">

When we view the source of the page in the web-browser, the URL listed for the image is:

http://server.name.here/context-root/faces/images/appimage.jpg

Why is it changing it to include "faces" in the URL name? Is that something that is a part of JSF where it automatically prepends relative URL's with "faces"?

Thanks again for all of your help!
 
Joseph Henstay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Varun,
Thanks for all of your help. I went and modified the developers code and changed it to utilize the HTML tags in JSF and sure enough, that fixed it!

Thanks again!
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great.
 
Joseph Henstay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
William,
Thanks for your reply as well. We tried this and that corrects the issue as well. Thanks again!
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic