JSP Layout is a simple sample project used to implement JSP layout support. This project only needs one servlet class and some configurations. The downloaded package contains a complete project, which can be directly imported into Eclipse for compilation. At runtime, you only need to configure a web application on Tomcat or other application servers, and point the path to the decompressed webapp directory. For example:
<Context path="" docBase="D:\WORKDIR\JSP Layout\webapp" reloadable="true"/>
Direct access after startup http://localhost:8080/ Or http://localhost:8080/hello.jspx You can see the effect.
The sample page consists of two parts:
1. hello.jsp (data page)
<%
request.setAttribute("layout","main.jsp");
Request. setAttribute ("page_title", "JSP X layout demonstration");
%>
2. main.jsp (layout page)
<html>
<head>
<title> ${page_title} </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
h1 {font-size:16pt;}
</style>
</head>
<body>
<h1>JSP layout demonstration</h1>
<hr/>
${screen_content}
<hr/>
<%=new java.util. Date()%>
</body>
</html>