Search code examples
jsptiles

Can i display a jsp page in tiles framework without splitting to header,footer& body


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.


Solution

  • 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
    
    <% } %>