1

How can I include a JSP page in a Facelets page?

mypage.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">

    <h:head>
        <meta charset="utf-8"></meta>
        <link href="css/bootstrap.css" rel="stylesheet"></link>
    </h:head>

    <h:body>


    </h:body>
</html>

header.jsp

<div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
            <div class="container">
                <div class="nav-collapse collapse">
                    <ul class="nav">
                        <li><a href="index.xhtml">Home</a></li>
                        <li><a href="login.xhtml">Login</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user1939400
  • 51
  • 2
  • 9

2 Answers2

3

Facelets has no builtin support for including JSP files. JSP is a deprecated view technology and Facelets is basically its successor. As JSP is deprecated, you shouldn't expect that there are any plans for its support.

Just rename header.jsp to header.xhtml and eliminate any JSP specific artifacts. There's nothing in JSP which would be "impossible" with JSF/Facelets.

As a temporary resort, you could use OmniFaces <o:resourceInclude> tag to embed the output of a JSP/Servlet page in Facelets. Note that it's thus like how <c:import> works and that it would only work with static content.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
1

Use OmniFaces http://omnifaces.org

You can use it in this way

<o:resourceInclude path="/someJSPpage.jsp" />

reference:

http://showcase.omnifaces.org/components/resourceInclude

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Netorica
  • 18,523
  • 17
  • 73
  • 108