• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Several folders for JSP in JSF

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are Ok.


Thank you very much.
 
reply
    Bookmark Topic Watch Topic
  • New Topic