include - JSTL taglibs not recognized when declared in common header -


i had idea while put of taglib declarations (uri's, etc) in common header file don't have manually write them of jsps. initially, things seemed fine, although don't use actual taglibs as simple el syntax. however, i'm having trouble in jsp files except 1 explicitly has taglibs declared. of other jsp's (that include header file) treat <c:something.../> tag if it's html , don't evaluate it. did googling , found this post on o'reilly suggesting i'm trying can done, i'm doing wrong. what's more other stuff in header file (common page headers, page titles, etc.) show fine. header file , sample of inclusion below.

header file:

<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ page session="false" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> 

inclusion statement:

<jsp:include page="/web-inf/jsp/include/header.jsp">     <jsp:param name="title" value="home" /> </jsp:include> 

this expected behaviour.

when use <jsp:include>, executed target in separate request, , includes output in including jsp. doesn't include source of included target, includes output. means target output generated lost.

to you're trying do, need use <% include %> directives:

<%@ include file="/web-inf/jsp/include/header.jsp" %> 

this incline literal text of header.jsp page. of course, doing that, can no longer pass parameters it, you'd need set page context attribute (e.g. using <c:set>... of course can't use <c:set> until you've done include...).

essentially, it's not worth hassle. taglib declarations annoying boilerplate, hard rid of.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -