Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8913469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:28:20+00:00 2026-06-15T04:28:20+00:00

Seems like JSPs, Velocity, Freemarker etc. can offer so-called inner templating: I can describe

  • 0

Seems like JSPs, Velocity, Freemarker etc. can offer so-called “inner templating”: I can describe an outer template, then define inner parts. Like this (simplified):

main.jsp:

<html>
<body>
    <div class="container">
        <%@ include file="menu.jsp"%>
        <%@ include file="content.jsp"%>
    </div>
</body>
</html>

So I can define menu.jsp and content.jsp and all works just fine. But here outer block has references to inners. Not very suitable for me.

I’m looking for technology for Java, that can let me implement something like this:

some_block.jsp:

<template file="main_template.jsp">
<div>
    ... my content here
</div>
</template>

main_template.jsp:

<html>
<body>
    <div class="container">
        <inner_content />
    </div>
</body>
</html>

I. e. vice versa – inner blocks have references to outer. Is it possible with JSPs? If not – what should I use with Spring MVC?

EDIT: Why it be more comfortable for me: when Controller receives a request, it detects what view it should render. So I can render, for example, feedback form:

feedback.jsp:

<template file="main_template.jsp">
    <form> ... feedback form content here ... </form>
</template>

or a product page product.jsp:

<template file="main_template.jsp">
    <div> ... product page content here ... </div>
</template>

and there is no need to describe page structure for every kind of pages, and there is no need to pass any parameters to outer template to render content correctly. And even no need in dynamic compilation – all pages are just an implicit set of precompiled servlets.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:28:21+00:00Added an answer on June 15, 2026 at 4:28 am

    I created a JSP taglib you might be interested in:

    http://www.inamik.com/projects/webframes/

    Here is how I would implement your request using the WebFrames taglib

    Notice that this is an exact 1-to-1 correlation to your example, but unlike your example, WebFrames allows you to create unlimited place-holders so you could have things like dynamic titles, css-includes, right-channel content, left-navs, etc.

    feedback.jsp

    <%@ page language="java" %>
    <%@ taglib prefix="wf" uri="/WEB-INF/tld/webframes.tld" %>
    <wf:render file="main_template.jsp">
        <wf:section name="inner_content">
            <form> ... feedback form content here ... </form>
        </wf:section>
    </wf:render>
    

    product.jsp

    <%@ page language="java" %>
    <%@ taglib prefix="wf" uri="/WEB-INF/tld/webframes.tld" %>
    <wf:render file="main_template.jsp">
        <wf:section name="inner_content">
            <div> ... product page content here ... </div>
        </wf:section>
    </wf:render>
    

    main_template.jsp

    <%@ page language="java" %>
    <%@ taglib prefix="wf" uri="/WEB-INF/tld/webframes.tld" %>
    <html>
    <body>
        <div class="container">
            <wf:render section="inner_content" />
        </div>
    </body>
    </html>
    

    Official WebFrames Example

    Below is the full example set from the website showing how you can create/populate multiple place-holders:

    http://www.inamik.com/projects/webframes/examples/simpleexample.jsp

    Start by looking at the source for the example main page:

    main http://www.inamik.com/projects/webframes/examples/simpleexample.jsp.txt

    <%@ page language="java" %>
    <%@ taglib prefix="wf" uri="/WEB-INF/tld/webframes.tld" %>
    <wf:render file="frame.jsp">
        <wf:section name="title">WebFrames Simple Example Page</wf:section>
        <wf:section name="header" file="headersection.html" />
        <wf:section name="footer" file="footersection.html" />
        <wf:section name="body">
            This page is a composite of the following sub-pages.  Click the links below to see
            the jsp/html that makes up each sub-page.
            <UL>
                <LI><A href="simpleexample.jsp.txt">simpleexample.jsp</A></LI>
                <LI><A href="frame.jsp.txt">frame.jsp</A></LI>
                <LI><A href="headersection.html.txt">headersection.html</A></LI>
                <LI><A href="footersection.html.txt">footersection.html</A></LI>
            </UL>       
        </wf:section>
    </wf:render>
    

    See how this defines the content sections without defining the layout.

    If you look at the layout (‘frame.jsp’) You’ll see it doesn’t know what content is going to be displayed, it just creates place-holders for the content:

    frame http://www.inamik.com/projects/webframes/examples/frame.jsp.txt

    <%@ page language="java" %>
    <%@ taglib prefix="wf" uri="/WEB-INF/tld/webframes.tld" %>
    <HTML>
    <HEAD><TITLE><wf:render section="title" /></TITLE></HEAD>
    <BODY>
        <TABLE width="100%">
            <!-- Header -->
            <TR>
                <TD>
                    <TABLE width="100%">
                        <TR>
                            <TD>
                                <wf:render section="header" />
                            </TD>
                        </TR>
                    </TABLE>
                </TD>
            </TR>
            <!-- Body -->
            <TR>
                <TD>
                    <TABLE width="100%">
                        <TR>
                            <TD>
                                <wf:render section="body" />
                            </TD>
                        </TR>
                    </TABLE>
                </TD>
            </TR>
            <!-- Footer -->
            <TR>
                <TD>
                    <TABLE width="100%">
                        <TR>
                            <TD>
                                <wf:render section="footer" />
                            </TD>
                        </TR>
                    </TABLE>
                </TD>
            </TR>
    </BODY>
    </HTML>
    

    header http://www.inamik.com/projects/webframes/examples/headersection.html.txt

    <!--  BEGIN headersection.html -->
    <TABLE bgcolor="#00C0C0" width="100%">
        <TR>
            <TD nowrap="nowrap" align="LEFT">
                <H1>WebFrames Sample Header</H1>
            </TD>
        </TR>
    </TABLE>
    <!-- END headersection.html -->
    

    footer http://www.inamik.com/projects/webframes/examples/footersection.html.txt

    <!--  BEGIN footersection.html -->
    <TABLE bgcolor="#00C0C0" width="100%">
        <TR>
            <TD nowrap="nowrap" align="CENTER">
                Copyleft (c) SampleFooter Inc.
            </TD>
        </TR>
    </TABLE>
    <!-- END footersection.html -->
    

    This pattern provides a much more flexible solution that creates components that are re-usable and easier to maintain.

    NOTES

    This was based on earlier work by David Geary:

    http://www.javaworld.com/javaworld/jw-12-2001/jw-1228-jsptemplate.html

    Also, if you’re willing (or considering) non-JSP solutions, I wrote a Java-based template engine in the spirit of PHP’s Smarty template engine

    https://github.com/iNamik/iNamik-Template-Engine

    I also have a ‘Frames’ taglib for this engine, which isn’t on GitHub yet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems like the slow Tomcat 7 startup problem can be resolved with metadata-complete set
Seems like everything worked fine when I pushed to Heroku as shown below. Then
Seems like a simple problem, but I can't find an answer. With cacheing disabled,
Seems like everyone have issue accessing local machine or internet etc from emulator. All
Seems like newbie's question, but I just can't find the answer. Can I somehow
Seems like I can't do this: private int[,] _table = new int[9, 9]; private
Seems like a super simple question but I can't find an answer. I'm grabbing
Seems like this should be the easy part, but I can't seem to get
Seems like a simple problem, but can't get this to work. In the example
Seems like a simple enough question but I can't seem to find the answer.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.