File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Include JSP/JSF pages into other JSP/JSF pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Include JSP/JSF pages into other JSP/JSF pages" Watch "Include JSP/JSF pages into other JSP/JSF pages" New topic

Include JSP/JSF pages into other JSP/JSF pages

David Brossard
Ranch Hand

Joined: Jun 03, 2004
Posts: 109
Hi all,

I am currently working on an icefaces-based web app and I would like to achieve the following:

I have page A which includes pages B, C, and D as the contents of panel tabs (ice:panelTab). To do so I use the ui:include element where ui points to the JSF Facelets namespace.

Page A starts with the usual following code:

I also want pages B through D to be standalone. In other words, I also want pages B through D to start with the same code snippet as aforementioned. However if I include that into A then I get 2 JSP roots and redefined namespaces. In the end it works fine nonetheless but it is extremely poor practice to do so.

My question is therefore whether there is a smart way to include files and remove the root and/or surperfluous elements & definitions.


No matter what they say in Ohio, we're still first in flight!
sri raman

Joined: Dec 03, 2009
Posts: 6
use <jsp:include> directive to add jsf/jsp pages.

If including JSF pages through the directive then the page being included should have contents nested inside <f:subview>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

When you use Facelets to include, each included item does have to be a properly-formed XML file, complete with whatever namespaces are referenced in that file. However what JSF assembles isn't going to include all these details. It uses them as part of the initial XML compilation process and discards them thereafter, when they're of no further use. If you read the JSF docs, you'll notice that Facelets ignores stuff outside the ui:component elements, for example.

You're probably worrying about a problem you don't actually have.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Include JSP/JSF pages into other JSP/JSF pages
It's not a secret anymore!