求助~Finally报错

qwjlegend 2010-09-26 11:10:09
<%@ page language="java" contentType="text/html; charset=GBK" import="java.sql.*" errorPage="error.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>验证用户身份</title>
</head>
<%
String ID = request.getParameter("ID");
String password = request.getParameter("password");
String info="0";
Connection con=null;
Statement sm=null;
ResultSet rs=null;
try{
Class.forName("com.sqlserver.jdbc.Driver").newInstance();
String url="jdbc:sqlserver://localhost/mydb1";
con=DriverManager.getConnection(url,"root","12345");
rs=sm.executeQuery("select * from userinfo where userid='"+ID+"'");
if(rs.next())
{
if(rs.getString("password").equals(password))
{
response.sendRedirect("Index.jsp");
session.setAttribute("user",ID);
}
else
response.sendRedirect("Logon.jsp?info=2");
}
else
{
response.sendRedirect("Logon.jsp?info=1");
}
}
catch(Exception e)
{
e.printStackTrace();
}

Finally{
if(rs!=null){
try{rs.close();}catch(Exception e){
e.printStackTrace();
}
}
if (sm!=null){
try{sm.close();}catch(Exception e){
e.printStackTrace();
}
}
if(con!=null)
{
try{con.close();}catch(Exception e){
e.printStackTrace();
}
}
}
%>

</html>



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: 40 in the jsp file: /Chklogon.jsp
Syntax error, insert "AssignmentOperator Expression" to complete Assignment
37: e.printStackTrace();
38: }
39:
40: Finally{
41: if(rs!=null){
42: try{rs.close();}catch(Exception e){
43: e.printStackTrace();


An error occurred at line: 40 in the jsp file: /Chklogon.jsp
Syntax error, insert ";" to complete Statement
37: e.printStackTrace();
38: }
39:
40: Finally{
41: if(rs!=null){
42: try{rs.close();}catch(Exception e){
43: e.printStackTrace();


An error occurred at line: 40 in the jsp file: /Chklogon.jsp
Finally cannot be resolved
37: e.printStackTrace();
38: }
39:
40: Finally{
41: if(rs!=null){
42: try{rs.close();}catch(Exception e){
43: e.printStackTrace();


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.
...全文
111 1 收藏 16
写回复
16 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
qwjlegend 2010-10-10
谢谢各位~~难怪,呵呵
回复
shanxmxj 2010-09-27
[Quote=引用 1 楼 lujun1985 的回复:]
finally是一个关键字,首字母不应该大写
[/Quote]


+1
回复
wei_wxx 2010-09-27
[Quote=引用 1 楼 lujun1985 的回复:]
finally是一个关键字,首字母不应该大写
[/Quote]

正解!
回复
yuxuan8701 2010-09-27
看不懂!
回复
njpingwen 2010-09-27
[Quote=引用 3 楼 niu90 的回复:]
finally,不是Finally
[/Quote]

正解
回复
zn85600301 2010-09-27
这错 确实 ···
回复
hongseyouyang 2010-09-27
[Quote=引用 3 楼 niu90 的回复:]

finally,不是Finally
[/Quote]
正解。。
回复
niu90 2010-09-27
finally,不是Finally
回复
kaida_7 2010-09-27
[Quote=引用 1 楼 lujun1985 的回复:]

finally是一个关键字,首字母不应该大写
[/Quote]正解。。。
回复
zcy9979420 2010-09-27
finally,不是Finally
回复
yearnqiao 2010-09-27
[Quote=引用 13 楼 hzz1988 的回复:]
引用 3 楼 niu90 的回复:
finally,不是Finally


正解··
[/Quote]

++++1
回复
hzz1988 2010-09-27
[Quote=引用 3 楼 niu90 的回复:]
finally,不是Finally
[/Quote]

正解··
回复
genguyige 2010-09-27
额 我也遇到过这样的问题 楼上正解 一般finally中是不会出现问题的~
回复
s0s0s0s 2010-09-27
是的!!
回复
f0501412727 2010-09-27
上面的已经解释了,大小写问题
回复
lujun1985 2010-09-26
finally是一个关键字,首字母不应该大写
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2010-09-26 11:10
社区公告
暂无公告