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 "Bryan P. Glennon" <br...@bpgc.com> on 2002/04/04 02:27:04 UTC

Taglibs and included pages

I'm seeing some strange (or maybe intended) behavior with taglibs and
included files. Here's what I do:

<%@ taglib prefix="bean" uri="/WEB-INF/struts-bean.tld" %>
<%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>

Normal JSP/HTML stuff...

<html:form  action="/action.do" style="margin-botton:0m"> 

<TABLE>
	    <jsp:include page="/Common/foo1.jsp"/>
	    <!-- Page specific rows go here -->
</TABLE>
<HR>
<TABLE>
	    <jsp:include page="/Common/foo2.jsp"/>
	    <!-- More page specific rows here -->
</TABLE>

</html:form>

More standard jsp/html

(foo1 and foo2 just contain table rows but do use the struts bean tag.)

The problem is with the two include files. If I don't repeat the <%
taglib> declarations 
in the included files, they don't work. It seems to me that once the
libs are declared, 
that declaration should hold for the remainder of the page. I'm sure I'm
missing something
here, and I'm looking for enlightenment. 

Any info is appreciated.

Cheers,
Bryan


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Taglibs and included pages

Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Bryan" == Bryan P Glennon <br...@bpgc.com> writes:

    Bryan> I'm seeing some strange (or maybe intended) behavior with taglibs and
    Bryan> included files. Here's what I do:

    Bryan> <%@ taglib prefix="bean" uri="/WEB-INF/struts-bean.tld" %>
    Bryan> <%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>

    Bryan> Normal JSP/HTML stuff...

    Bryan> <html:form  action="/action.do" style="margin-botton:0m"> 

    Bryan> <TABLE>
    Bryan> 	    <jsp:include page="/Common/foo1.jsp"/>
    Bryan> 	    <!-- Page specific rows go here -->
    Bryan> </TABLE>
    Bryan> <HR>
    Bryan> <TABLE>
    Bryan> 	    <jsp:include page="/Common/foo2.jsp"/>
    Bryan> 	    <!-- More page specific rows here -->
    Bryan> </TABLE>

    Bryan> </html:form>

    Bryan> The problem is with the two include files. If I don't repeat the <%
    taglib> declarations 
    Bryan> in the included files, they don't work. It seems to me that once the
    Bryan> libs are declared, 
    Bryan> that declaration should hold for the remainder of the page. I'm sure I'm
    Bryan> missing something
    Bryan> here, and I'm looking for enlightenment. 

It helps to understand how the JSP include "action" works, as opposed to the
include "directive".  Your main JSP and your included JSP pages are all
compiled into individual servlets.  They have to be able to work independently
(even if they're generating only a fragment of the output).

The include "action" happens at execution time, whereas the include "directive"
happens at compile time.  You could get away with leaving out the taglib
declarations in the included pages if they were included with the directive,
but not if they were included with the action.

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Taglibs and included pages

Posted by Shawn Bayern <ba...@essentially.net>.
On Wed, 3 Apr 2002, Bryan P. Glennon wrote:

> The problem is with the two include files. If I don't repeat the <%
> taglib> declarations in the included files, they don't work. It seems
> to me that once the libs are declared, that declaration should hold
> for the remainder of the page. I'm sure I'm missing something here,
> and I'm looking for enlightenment.

When you include files with <%@ include %>, they are incorporated into the
source file, and you wouldn't need to re-declare taglibs with <%@ taglib
%>.  However, <jsp:include> lets you include full, stand-alone pages (and
other resources).  More formally, <jsp:include> includes a separate
translation unit, so the target page will still need its own declarations.

-- 
Shawn Bayern
Author, "JSP Standard Tag Library"  http://www.jstlbook.com
(coming this summer from Manning Publications)


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>