<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>Include 页面</title> </head> <body> <%out.println("include指令的使用,我是被包含过来的页面内容"); %> </body> </html>
<%@ include file="relativeURL" %> 可以把其他页面包含至当前位置。