为什么有一些jsp不能编译?
我练习书上的例子,基本能成功,今天在网上复制了一个jsp,使用数据源的,放在tomcat的目录下,但是在浏览器中输入jsp的名字,出现以下错误,请大侠帮助解答啊!
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /sessiontest/test.jsp
Syntax error on token "Invalid Character ", delete this token
3: <%@ page import= "javax.sql.* "%>
4: <%@ page import= "javax.naming.* "%>
5: <%@ page session= "false " %>
6: <%
7: DataSource ds = null;
8: try
9: {
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
[解决办法]
检查你下你的 <%%> 之间的代码,是不是有全角空格之类的不可见符号
注意是全角的
[解决办法]
<%
7: DataSource ds = null;
8: try
9: {
<%DataSource ds = null;
try
{
....
....
或者拿到IDE中,应该会显示出错误提示,eclipse or JBuilder
[解决办法]
其实你可以把 <%%> 中的代码重新输入一遍的
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html