Gerixxx
Gerixxx

Reputation: 47

Insert XHTML content in JSP file

I have to insert an XHTML content into my JSP file, but I don't know how to do it. Someone told me, that I have to use p:view tag, but the question is the same: how?

Thanks for answers!

Upvotes: 0

Views: 1333

Answers (2)

bgoldst
bgoldst

Reputation: 35314

Just to add another approach, you can also use tag files. These are more powerful than JSP include directives because they allow argument passing from the including JSP or tag file to the included tag file. Here's an example:

WEB-INF/tags/namespace/head.tag:

<%@attribute name="name" required="true"%>

<script type="text/javascript" src="blah.js"></script>
<style type="text/css">.class1 { color:${name}; }</style>

home.jsp:

<!DOCTYPE html>

<%@taglib prefix="namespace" tagdir="/WEB-INF/tags/namespace"%>

<html>
<head>
    <title>Home</title>
    <namespace:head name="red"/>
</head>

<body>
    <div class="class1">red div</div>
</body>

</html>

Upvotes: 0

bgoldst
bgoldst

Reputation: 35314

You can paste a file into a JSP servlet during translation using the include directive:

<%@include file="includee.xhtml" %>

Upvotes: 1

Related Questions