Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Images not displaying using JSF?  RSS feed

 
Joseph Henstay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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!
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
Scott Duncan
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Great.
 
Joseph Henstay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William,
Thanks for your reply as well. We tried this and that corrects the issue as well. Thanks again!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!