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 8709725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:26:12+00:00 2026-06-13T04:26:12+00:00

I am now trying to make a small website with jsp, just like most

  • 0

I am now trying to make a small website with jsp, just like most index pages, the index page of my website will include some part: The top part(contain a logo and a menu), the main part, the bottom part. In order to avoid too many html labels fill in the index pages, maybe including pages will be a good idea.

After search, I know that there are two methods to include jsp pages:use <%@ include file=""%> or <jsp:include page=""> and I know there are some differences between them, but I still meet some problems with include pages.

if I have a index.jsp and top.jsp I want to include top.jsp in the index.jsp.

The index.jsp like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>title</title>
<style type="text/css">
  body {background-color:black;margin:0px;padding:0px;}
  #left,#right {width:10%;margin:0px;padding:0px;}
  #left,#center,#right {float:left;}
  #center {width:80%;}
  #top {height:150px;}
  #main {height:600px;background-color:white;}
</style>
</head>

<body>
<div id="left">&nbsp;</div>
<div id="center">
  <div id="top"><jsp:include page="top.jsp"/></div>
  <div id="main"></div>
  <div id="bottom"></div>
</div>
<div id="right">&nbsp;</div>
</body>
</html>

top.jsp like this:

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>  
<div id="logo"><img width="80px" height="65px" src="images/logo.jpg"></div>
<div id="menu">
<p>
  <a href="">hello</a>
  <a href="">work</a>
  <a href="">contact me</a>
</p>
</div>
</body>
</html>

My questions are as follow:

1.no matter which method of the two I use, where I click “look the source code” in the browser,I get this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>title</title>
<style type="text/css">
  body {background-color:black;margin:0px;padding:0px;}
  #left,#right {width:10%;margin:0px;padding:0px;}
  #left,#center,#right {float:left;}
  #center {width:80%;}
  #top {height:150px;}
  #main {height:600px;background-color:white;}
</style>
</head>

<body>
<div id="left">&nbsp;</div>
<div id="center">
  <div id="top"><html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>  
<div id="logo"><img width="80px" height="65px" src="images/logo.jpg"></div>
<div id="menu">
<p>
  <a href="">hello</a>
  <a href="">work</a>
  <a href="">contact me</a>
</p>
</div>
</body>
</html>
</div>
  <div id="main"></div>
  <div id="bottom"></div>
</div>
<div id="right">&nbsp;</div>
</body>
</html>

the code in the top.jsp include the content in the head appear in the index.jsp, I think maybe I make some mistake and it should like this.

2.If I only write some lebels like this:

<div id="logo"><img width="80px" height="65px" src="images/logo.jpg"></div>
<div id="menu">
<p>
  <a href="">hello</a>
  <a href="">work</a>
  <a href="">contact me</a>
</p>
</div>

Then if the code contains some characters that do not supported by “ISO-8859-1”, myeclipse will report a wrong info dialog.
So how should I include a jsp page correctly?
Thank you!

Liu Peng

  • 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-13T04:26:13+00:00Added an answer on June 13, 2026 at 4:26 am

    JSP won’t remove the <html><head><body> for you during <jsp:include>. It just includes all its output unmodified. If you need auto-removal of irrelevant HTML elements, you should be using a templating-capable view technology, such as JSP’s successor Facelets, or some 3rd party library like Velocity, Freemarker and so on.

    Your top.jsp really needs to contain only the content which you really need to have to end up in the final HTML product at exactly the location where <jsp:include> is declared in the parent page. Just keep the <html><head><body> out from top.jsp.

    As to character encoding issues, this is a different matter, unrelated to whether the JSP is included or not. You just need to add a <%@page pageEncoding="UTF-8" %> to top of every JSP to tell the container that it should process the JSP using the given character encoding. UTF-8 is the de facto standard which covers every single character the mankind is aware of. To prevent repeating the same line over every single JSP, add this to web.xml instead:

    <jsp-config>
        <jsp-property-group>
            <url-pattern>*.jsp</url-pattern>
            <page-encoding>UTF-8</page-encoding>
        </jsp-property-group>
    </jsp-config>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make some small adjustments to a very big website (not
I am trying to make a chatroom layout like the following: Now my problem
I am just messing around trying to make a game right now, but I
i'm trying to make a form for my website, to transfer some data easily.
I'm trying to make a small program more robust and I need some help
right now I am trying to make a website Portfolio and I am running
I'm currently trying to make a small application that performs different duties. Right now
Trying to make some small changes to Apache's Velocity engine. Here's what I can
So I'm just trying to create a small website. (Don't worry that's not going
i usually develop for iPhone. But now trying to make a pong game in

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.