我输出简单的jsp页面能编译出来,如: <% String s="HELLO WORLD"; %>
<%=s%>可是以下代码就不行了(连接Oracle数据库的操作)!<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><%@ page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head> <title>My JSP 'index.jsp' starting page</title>
</head>
<body><br>
<%!
public static final String DBDRIVER = "oracle.jdbc.driver.OracleDriver" ;
public static final String DBURL = "jdbc:oracle:thin:@localhost:1521:test" ;
public static final String DBUSER = "scott" ;
public static final String DBPASSWORD = "tiger" ;
%>
<%
Conntection conn=null;
PreparedStatement pst=null;
ResultSet rs=null;
.........
就报错:
org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 20 in the jsp file: /emp_list.jsp
Conntection cannot be resolved to a type
17: public static final String DBPASSWORD = "tiger" ;
18: %>
19: <%
20: Conntection conn=null;
21: PreparedStatement pst=null;
22: ResultSet rs=null;
<%=s%>可是以下代码就不行了(连接Oracle数据库的操作)!<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><%@ page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head> <title>My JSP 'index.jsp' starting page</title>
</head>
<body><br>
<%!
public static final String DBDRIVER = "oracle.jdbc.driver.OracleDriver" ;
public static final String DBURL = "jdbc:oracle:thin:@localhost:1521:test" ;
public static final String DBUSER = "scott" ;
public static final String DBPASSWORD = "tiger" ;
%>
<%
Conntection conn=null;
PreparedStatement pst=null;
ResultSet rs=null;
.........
就报错:
org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 20 in the jsp file: /emp_list.jsp
Conntection cannot be resolved to a type
17: public static final String DBPASSWORD = "tiger" ;
18: %>
19: <%
20: Conntection conn=null;
21: PreparedStatement pst=null;
22: ResultSet rs=null;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货