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"> </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"> </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"> </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"> </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