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

how to make links to pages inside sub directories

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

I have problem to link pages. I used <h:link> which is fine and working when all pages in the same directory. but when I try to link the pages that are located in sub directories. It is now working. here is some code, if anyone can help me.
this code is perfectly working


but the following code does not works


I am try to link a page from a directory called staff to main page in another directory called admin

I appreciate your help.



 
Saloon Keeper
Posts: 28126
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your first mistake was when you used the term "directory". URLs may look like filesystem paths, but they are not filesystem paths. They are resource locator strings. The slashes are simply parts of the URL strings and only have special meaning if the webapp wants them to have special meaning. There's no actual "directory" in a URL.

Sometimes a URL may be parsed by the webapp and part of the URL is then applied as an internal resource path (for example, "images/pic1.jpg"), but that's only because the webapp decided to map things that way. It could have done something entirely different with the URL if it wanted to.

The h:link element is new to JSF2. I'm not quite sure what it does that the older h:outputLink tag didn't, although I suspect that it may have to do with the ability to add parameter options to the resulting URL as well as the fact that it can accept JSF navigation targets for their "outcome".

Relative link locations can be tricky in J2EE, but JSF can make that better because it allows you to use absolute locations, instead. Normally to get the true URL of a J2Ee resource, you'd have to know the context path that the app was deployed under, but by using this feature, you can code a portable path. For example:


Notice that this is an "absolute" location because it begins with "/" instead of ".."
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Woowwww Tim,

Thank you very much for this clear information, I have to mention that I am not an experienced programmer, and this is how I learn.

yea as you said, when I removed ../, and tried with absolute URLs, it is perfectly working.

Thank you very much
 
Farmers know to never drive a tractor near a honey locust tree. But a tiny ad is okay:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic