views:

205

answers:

1

I am using Tiles within my web-application. I have a standard-layout (standard.jsp) within the tiles are used. On top of the standard.jsp are a lot of includes, concerning tag-libraries and such.

Let's do a simplified example.

standard.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/includes/include.jsp" %>

<html>

<head>
    <tiles:insertAttribute name="head" flush="false"/>
</head>

<body>
    <tiles:insertAttribute name="body" flush="false"/>
</body>    

</html>

body.jsp:

<div id="body-div">
    <p>Hello, <c:out value="${forname}" />!</p>
</div>

This prints:

Hello, !

In the tiles I would like to use the tags, but it's not working. It only works, if I add the includes to the tile-jsp.

body.jsp with includes:

<%@ include file="/WEB-INF/jsp/includes/include.jsp" %>

<div id="body-div">
    <p>Hello, <c:out value="${forname}" />!</p>
</div>

This prints:

Hello, John!

Is there a better way to do this or do I have to add all includes to every jsp used?

+1  A: 

Hi,

You don't need ALL includes to be present in each of your tiles, but each used tag-library in a tile must specifically be included in the using tile.

eg : In your example, each tile using the C JSTL library should at least have the <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> include

WiseTechi
Thank you for your response.Is it a huge performance issue, if I include "all includes" or only the relevant?
bitschnau
If these includes are basically TLDs I don't think it is a huge performance issue.If they include javascripts libraries, css or so, you may consider splitting your global include.jsp into more specific ones.
WiseTechi