tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <>
Subject Re: JSTL Tag in a directive.
Date Sun, 06 Jul 2003 01:38:38 GMT
Rick Ross wrote:
> I can't seem to get this to work:
> <%@ includes file="<c:out value='${includePage}' />" %>
> I didn't see anything in the Spec that suggests that it would violate spec,
> but it wasn't mentioned either (as far as I saw.)

Rick, time to read a good book about JSP ;-) There are two ways to include
files defined by the JSP spec, and JSTL adds a third. The "include" directive
you're using here is a staticly including content. It works just like an
#include in C, and is processed when the JSP page is turned into a servlet.

Hence, the file name is fixed; you can't define it as a dynamic value,
not even if you use correct syntax (tags can never be used as attribute
values) ;-)

> Since I need the contents of "includePage" to be processed as JSP, I think I
> am SOL and will have to wrap it in a choose/when tag
> <c:choose> <c:when test="${includePage == 'somepage.jsp' > <%@ includes
> file="somepage.jsp" %> </c:when> </c:choose>
> Am I missing something?  The reference is always local, but when I tried
> <c:import> It wouldn't process the JSTL tags in somepage.jsp.
> I appreciate any feedback

You can either use the standard <jsp:include> tag:

   <jsp:include page="<%= includePage %>" />

or the JSTL <c:import> tag:

   <c:import url="${includePage}" />

The main differences are that you must use a Java expression as the
attribute value for <jsp:include> in JSP 1.2 (in JSP 2.0, you can use
an EL expression) and that the semantics for <c:import> are better
defined for error cases (e.g., page not found). <c:import> is also able
to include data from external resources, like a different web app in
the same server or even from a different server; <jsp:include> only
support include of resources in the same web app.

Hope this helps,
Hans Bergsten                                <>
Gefion Software                       <>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at                                    <>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message