求助~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.
...全文
158 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
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是一个关键字,首字母不应该大写

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧