This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Several folders for JSP in JSF  RSS feed

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I�m trying to develop a JSF appliation, and I�ve decided to divide
JSP files in several groups of folders. (web/products/, web/users/... you know.)

Well, my problem is that when I want to refer an image, or a css, I cannot put a relative url because I cannot write someting like this:
<%
String CONTEXT=request.getContextPath();
%>
...
<h:graphicImage value="<%=CONTEXT%>/pages/img/logo.gif"></h:graphicImage>

It fails!!

or even
<h:graphicImage value="#{anyBean.imageUrl}"></h:graphicImage>

It fails, too.

So, �its necessary to put every jsp in the same folder to avoid this?



please help!! And forgive my "survival" English.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to learn about relative paths.

The leading slash in a relative URL will point to the domain root. If this page is requested by for example "http://example.com/webapp/pages/page.jsf", then the relative URL "/images/1.jpg" will point to "http://example.com/images/1.jpg". If there is no leading slash, then it will be relative to the current root. E.g. "images/1.jpg" will point to "http://example.com/webapp/pages/images/1.jpg". If you want to get a directory up, add "../" to the relative URL. E.g. "../images/1.jpg" would then point to "http://example.com/webapp/images/1.jpg".

It is almost the same as file system paths. There is absolutely no need to get and inline context paths, unless you want an absolute path which is independent from the environment.
[ August 27, 2008: Message edited by: Bauke Scholtz ]
 
David Carrascal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are Ok.


Thank you very much.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!