求助~Finally报错
<%@ 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.