org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 3 in the jsp file: /ch3-4-include1.jspDuplicate local variable path1: <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>2: <%3: String path = request.getContextPath();4: String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";5: %>6: An error occurred at line: 4 in the jsp file: /ch3-4-include1.jspDuplicate local variable basePath1: <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>2: <%3: String path = request.getContextPath();4: String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";5: %>6: 7: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
源码:
<!--ch3-4-include1.jsp-->
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
?<head>
???<title>被include包含的文件</title>
?</head>
?<body>
<h1>Hello World!</h1>
?</body>
</html>
<!--ch3-4-include2.jsp-->
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
?<head>
???<base href="<%=basePath%>">
???
???<title>include指令实例</title>
?</head>
?<body>
<center>
现在的日期和时间是:<%=new Date() %>
<hr>
<%@ include file="ch3-4-include1.jsp" %>
</center>
?</body>
</html>
这个错误是在我的这个代码里面是ch3-4-include1.jsp文件里多了 import="java.util.*"
然后把这个import="java.util.*"删除就不报错误了。再把其他多余的代码删掉
2: <%3: String path = request.getContextPath();4: String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";5: %>6: 7: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
类似这些的删掉!!
org.apache.jasper.JasperException: Unable to compile class for JSP: 解决办法
原文地址:http://www.cnblogs.com/qq1206050421/p/7753261.html