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

  • Home
  • SEARCH
  • 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 6093545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:34:20+00:00 2026-05-23T12:34:20+00:00

I have a complicated website design (downloaded a design + css from the web)

  • 0

I have a complicated website design (downloaded a design + css from the web) and I want to cleverly use includes, so that I can separate the design from the content.

However, there’s some complication with that. the content is located inside a <div> which is inside a <div>, etc.
How do I use includes so that basically, I can have each repeatable aspect of the site (header, navigation) in its own file, and for every actual page, have none of the design in the jsp?

i.e., in a certain page, I only want to have

//possible includes
<h1>Hello World!</h1>
//possible includes
  • 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-05-23T12:34:20+00:00Added an answer on May 23, 2026 at 12:34 pm

    You should probably look at Apache Tiles since it does most of this for you.

    If you want to roll your own you can create two files, say header.jsp and footer.jsp with the start and end of the page:

    header.jsp

     <html>
       <head>
       </head>
       <body>
          <div>
            //header content
          </div>
          <div>
          //main content
    

    and, footer.jsp

          </div>
        </body>
      </html>
    

    And include both in your content pages.

    Alternatively, you can create a single layout.jsp page:

      <html>
       <head>
       </head>
       <body>
          <div>
            //header content
          </div>
          <div>
          <c:out value="${content}"/>
          </div>
        </body>
      </html>
    

    Then all request will populate the content variable then load the layout page. This way you do not have to repeat the includes all over the place.

    Example:
    In your servlet you can give the variable a value like this:

            String content = "<h1>Hello World!</h1>";
            request.setAttribute("content", content);
            //forward to layout.jsp
    

    This way, on the layout.jsp page the content will be displayed. You can of course create several such variable placeholders.

    Third Option:
    Use a jsp:include tag to include dynamic content. For example
    The layout.jsp page will look like this:

        <html>
           <head>
           </head>
           <body>
             <div>
               //header content
             </div>
             <div>
               <jsp:include page="${page}"/>
             </div>
           </body>
        </html>
    

    The include tag will fetch the page at the given url. The reason for using this suggestion is when you have more complicated displays it would be better to use a JSP page to construct the display. The servlet will then only be concerned with the business logic. You can create a separate jsp page for each display. The servlet will look like this:

        //business logic
        //save the data to be displayed in the request
        String page = "nextpagetodisplay.jsp";
        request.setAttribute("page", page);
        //forward to layout.jsp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty complicated Linq query that I can't seem to get into
I have a highly complicated web site that is under source control and has
I have a website where my customers can login. Some of them complains that
We have an ASP.NET website that we use internally to do some project tracking
I have a complicated MySQL query which takes a lot of time, selecting from
I have a complicated report that I need to draw with GDI+ (I don't
Im having a very strange problem, i have a complicated view that returns incorrect
I have some really complicated legacy code I've been working on that crashes when
I have inherited two complicated COM objects. One was derived from the other and
I have an asp.net-mvc3 website using nhibernate and SQL server. I have 2 web

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.