1
votes

I have a jsp file with header,footer and body.i want to display the complete page with tiles without splitting the page into header,footer body pages.

here is the tiles definition

    <definition name="homepage" template="pages/intro.jsp">
        <put-attribute name="header" value="/pages/HomeHead.jsp" />
        <put-attribute name="body" value="pages/HomeBody.jsp" />
        <put-attribute name="footer" value="/pages/HomeFooter.jsp"/>
    </definition>

a single jsp page is split into header.jsp,footer.jsp,body.jsp .can i display the jsp page without splitting into header,footer and body.

2
can you please put some more details with example?Amey Jadiye
i just edited my questionAkhil Jayakumar
do you mean something like this? <definition name="singlePage" extends=homepage"> <put-attribute name="header" value="/pages/empty.jsp" /> <put-attribute name="body" value="/WEB-INF/jsp/singlpage.jsp" /> <put-attribute name="footer" value="/WEB-INF/empty.jsp" /> </definition> ?Si mo

2 Answers

0
votes

There are some ways you can do that, first you can create a new template extending your old template:

<definition name="OnlyBodyPage" extends=homepage">

and set footer and header as empty jsp's:

<put-attribute name="header" value="blankPage.jsp" /> 
<put-attribute name="footer" value="blankPage.jsp" /> 

Another way, is using conditional statements, for example:

<% if (youWantDefinition1) { %>

    //My incredible code

<% } else { %>

   //My amazing code

<% } %>
0
votes

I had the same requirement, I resolve it by making a new layout page

layoutmanager.jsp

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  
     "http://www.w3.org/TR/html4/loose.dtd">
  <html>

  <head>
    <title>
      <tiles:getAsString name="title" />
    </title>
  </head>

  <body>

    <%-- <%@  include file="header.jsp" %> --%>
      <tiles:insertAttribute name="body" />
    <%-- <%@ include file="footer.jsp" %> --%>

  </body>

  </html>

tiles.xml

 <?xml version="1.0" encoding="UTF-8" ?>   
      
    <!DOCTYPE tiles-definitions PUBLIC   
    "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"  
     "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">   
      
    <tiles-definitions>  
         
       <definition name="login" template="/layoutmanager.jsp">   
       <put-attribute name="title" value="Login Page"/>   
       <put-attribute name="body" value="/loginPage.jsp"/>   
       </definition>    
         
    </tiles-definitions>