2

I design a JSP-Template, just like @Will Hartung great example (Link), I have genericpage.tag :

 <%@tag description="Overall Page template" pageEncoding="UTF-8"%>
 <%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
 <%@attribute name="header" fragment="true" %>
 <%@attribute name="footer" fragment="true" %>
 <html>
   <body>
     <div id="pageheader">
       <jsp:invoke fragment="header"/>
     </div>
     <div id="body">
       <jsp:doBody/>
     </div>
     <t:page.footer>
       <jsp:invoke fragment="footer"/>
     </t:page.footer>                    
   </body>
 </html>

and as you see i defined page.footer.tag in my genericpage.tag with this content :

page.footer.tag :

<%@attribute name="footer" fragment="true" %>
<div id="footer">
    <jsp:invoke fragment="footer"/>
</div>

in my JSP page i have :

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
<t:genericpage>
    <jsp:attribute name="header">
      <h1>Welcome</h1>
    </jsp:attribute>
    <jsp:attribute name="footer">
      <p id="copyright">Copyright 1927, Future Bits When There Be Bits Inc.</p>
    </jsp:attribute>
    <jsp:body>
       <p>Some Content</p>        
    </jsp:body>
</t:genericpage>

The header attribute are work fine, but when i send a footer attribute into the other tag page (page.footer.tag) it doesn't work

on the other hand the header and footer attribute are work fine when i use it in genericpage.tag but they doesnt work in neasted tag like page.footer.tag which i use into the genericpage.tag

Community
  • 1
  • 1
Kamyar Gilak
  • 1,044
  • 2
  • 17
  • 23

1 Answers1

0

Also you can do something like this. In your principal jsp u need to put this code :

< jsp:include page="example.jsp" >

example.jsp:

< %@ page contentType="text/html;charset=windows-1252"% >

and your code..