You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Rick Ross <rr...@stupendousman.com> on 2003/07/06 03:23:42 UTC
JSTL Tag in a directive.
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.)
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
Rick
Re: JSTL Tag in a directive.
Posted by Hans Bergsten <ha...@gefionsoftware.com>.
I think I missed an important point, see intermixed below.
Hans Bergsten wrote:
> 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.
Do you declare the JSTL tag libraries in somepage.jsp? A dynamically
included/imported page is processed as a completely separate entity, so
it doesn't know about any tag library declarations you've made in the
importing page.
>> 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
--
Hans Bergsten <ha...@gefionsoftware.com>
Gefion Software <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at <http://TheJSPBook.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: JSTL Tag in a directive.
Posted by Hans Bergsten <ha...@gefionsoftware.com>.
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
--
Hans Bergsten <ha...@gefionsoftware.com>
Gefion Software <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at <http://TheJSPBook.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: JSTL Tag in a directive.
Posted by "N. Chen" <ni...@u.washington.edu>.
you can use <c:import> instead of <%@ include>, i think that would solve
your problem.
nick
On Sat, 5 Jul 2003, 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.)
>
> 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
>
> Rick
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org