主题:这问题怎么解决?
大家帮帮忙!看看问题出在哪里了!以下是程序和出现的问题
<%@ page contentType="text/html;charset=gb2312"%>
<!-导入程序所需的相应的包packages,一般jsp中进行数据库操作都可以引入这些类包->
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<html>
<head>
<title>信息查询</title>
</head>
<body>
<% String kind="";
String keyword="";
request.setCharacterEncoding("GB2312");
kind=request.getParameter("kind");
keyword=request.getParameter("keyword");%>
<% String attribute="";
if(kind.equals("职工号")) attribute="职工号";
else if(kind.equals("姓名")) attribute="姓名";
else if(kind.equals("性别")) attribute="性别";
else if(kind.equals("参加工作")) attribute="参加工作";%>
<% try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
String url="jdbc:odbc:employees";
Connection conn=DriverManager.getConnection(url,"","");
Statement smt=conn.createStatement();
String sql="Select * from worker where "+attribute+" like'"+keyword+"'";
ResultSet rs=smt.executeQuery(sql);
out.print("<TABLE BORDER>");
out.print("<CAPTION><H2>本次浏览数据库的结果如下</CAPTION>");
out.print("<TR align=center>");%>
<%
out.print("<TD>职工号</TD><TD>姓名</TD><TD>性别</TD><TD>参加工作</TD></TR>");
while(rs.next()){
out.print("<TR>");
for(int i=1;i<=rs.getMetaData().getColumnCount();i++){
out.print("<TD>");
out.print(rs.getObject(i)+"\t");
out.print("</TD>");}
out.print("<TD><A href=http://>请点击这里</A></TD>");
out.println("</TR>");}
out.print("</TABLE>");
rs.close();
smt.close();
conn.close();
}catch(Exception e){out.println(e.toString());}
%>
</body>
</html>
初学jsp,求助!
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: 24 in the jsp file: /textsql.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\textsql_jsp.java:78: "try" ??? "catch" ? "finally"
try{
^
1 ??
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:437)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:497)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:476)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:464)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs
<%@ page contentType="text/html;charset=gb2312"%>
<!-导入程序所需的相应的包packages,一般jsp中进行数据库操作都可以引入这些类包->
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<html>
<head>
<title>信息查询</title>
</head>
<body>
<% String kind="";
String keyword="";
request.setCharacterEncoding("GB2312");
kind=request.getParameter("kind");
keyword=request.getParameter("keyword");%>
<% String attribute="";
if(kind.equals("职工号")) attribute="职工号";
else if(kind.equals("姓名")) attribute="姓名";
else if(kind.equals("性别")) attribute="性别";
else if(kind.equals("参加工作")) attribute="参加工作";%>
<% try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
String url="jdbc:odbc:employees";
Connection conn=DriverManager.getConnection(url,"","");
Statement smt=conn.createStatement();
String sql="Select * from worker where "+attribute+" like'"+keyword+"'";
ResultSet rs=smt.executeQuery(sql);
out.print("<TABLE BORDER>");
out.print("<CAPTION><H2>本次浏览数据库的结果如下</CAPTION>");
out.print("<TR align=center>");%>
<%
out.print("<TD>职工号</TD><TD>姓名</TD><TD>性别</TD><TD>参加工作</TD></TR>");
while(rs.next()){
out.print("<TR>");
for(int i=1;i<=rs.getMetaData().getColumnCount();i++){
out.print("<TD>");
out.print(rs.getObject(i)+"\t");
out.print("</TD>");}
out.print("<TD><A href=http://>请点击这里</A></TD>");
out.println("</TR>");}
out.print("</TABLE>");
rs.close();
smt.close();
conn.close();
}catch(Exception e){out.println(e.toString());}
%>
</body>
</html>
初学jsp,求助!
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: 24 in the jsp file: /textsql.jsp
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\textsql_jsp.java:78: "try" ??? "catch" ? "finally"
try{
^
1 ??
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:437)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:497)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:476)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:464)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs