File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes how to make links to pages inside sub directories Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "how to make links to pages inside sub directories" Watch "how to make links to pages inside sub directories" New topic

how to make links to pages inside sub directories

Farhad Rahmati
Ranch Hand

Joined: Dec 16, 2010
Posts: 96
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.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964

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 hutputLink 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 ".."

Customer surveys are for companies who didn't pay proper attention to begin with.
Farhad Rahmati
Ranch Hand

Joined: Dec 16, 2010
Posts: 96
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
I agree. Here's the link:
subject: how to make links to pages inside sub directories
Similar Threads
JQuery XML parsing and HTML construction
JSF 2.0 ActionMethod with Parameter
<h:commandLink> rendered not updating on logout
Send value to mulitple beans
JSF, Facelets losing context after reload