V
vicchen0
Unregistered / Unconfirmed
GUEST, unregistred user!
我的调试环境是weblogic8.0+windows2000ser+java2,1.4
我每一次调试都会出现在这样的错误:
[red]Error 500--Internal Server Error
java.lang.ClassCastException
at jsp_servlet._yysbgl.__checklogin._jspService(__checklogin.java:130)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6291)
at weblogic.security.acl.internal.Authen
ticatedSubject.doAs(Authen
ticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:97)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3575)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2573)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)[/red]
我的其它代码如下:
DBCon.java的代码是:
[blue]package yysbgl;
import java.io.*;
import javax.servlet.http.*;
import java.sql.*;
public class DBCon implements HttpSessionBindingListener{
private Connection con = null;
/** Creates a new instance of DBCon */
public DBCon() { //在构造函数中完成数据库连接
BulidConnection();
}
private void BulidConnection() {
try{
java.sql.DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con=DriverManager.getConnection("jdbcracle:thin172.21.160.242:1521:shendayy", "yysbgl", "sb3451827");
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
//返回Connection对象的方法
public Connection getConnection() {
//若con为null时,重新建立数据库链接
if(con==null)
BulidConnection();
return this.con;
}
public void close() {
try{
con.close();//关闭Connection对象
con=null;
}
catch(SQLException sex)
{
System.out.println(sex.toString());
}
}
public String chinese(String source) {
try
{
String _temp = "";
byte[] _byte = source.getBytes("iso-8859-1");
_temp = new String(_byte, "GB18030");
source=_temp;
}
catch (Exception ex)
{
System.out.println(ex.toString());
}
return source;
}[/blue]
//当对象加入session时,将自动执行
public void valueBound(HttpSessionBindingEvent event) {
}
//当session对象中止时,将自动执行此函数
public void valueUnbound(HttpSessionBindingEvent event) {
if(con!=null)
close();//调用close方法
}
}
网页的代码如下:
<%@page contentType="text/html;charset=Gb2312" import="java.sql.*"%>
<html>
<head><title>jsp</title></head>
<body>
<jsp:useBean id="ConBean" scope="session" class="yysbgl.DBCon"/>
<%
java.sql.Statement stmt=null;
//String strSQL="select * from dlgh";
java.sql.Connection con=ConBean.getConnection();
stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
java.sql.ResultSet rs=stmt.executeQuery("select * from dlgh");
while(rs.next())
{
%>
<%=rs.getString("DLGH_GH")%>
<%
}
rs.close();
stmt.close();
ConBean.close();
%>
</body>
</html>
请问问题出在那里呢?
我每一次调试都会出现在这样的错误:
[red]Error 500--Internal Server Error
java.lang.ClassCastException
at jsp_servlet._yysbgl.__checklogin._jspService(__checklogin.java:130)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6291)
at weblogic.security.acl.internal.Authen
ticatedSubject.doAs(Authen
ticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:97)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3575)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2573)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)[/red]
我的其它代码如下:
DBCon.java的代码是:
[blue]package yysbgl;
import java.io.*;
import javax.servlet.http.*;
import java.sql.*;
public class DBCon implements HttpSessionBindingListener{
private Connection con = null;
/** Creates a new instance of DBCon */
public DBCon() { //在构造函数中完成数据库连接
BulidConnection();
}
private void BulidConnection() {
try{
java.sql.DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con=DriverManager.getConnection("jdbcracle:thin172.21.160.242:1521:shendayy", "yysbgl", "sb3451827");
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
//返回Connection对象的方法
public Connection getConnection() {
//若con为null时,重新建立数据库链接
if(con==null)
BulidConnection();
return this.con;
}
public void close() {
try{
con.close();//关闭Connection对象
con=null;
}
catch(SQLException sex)
{
System.out.println(sex.toString());
}
}
public String chinese(String source) {
try
{
String _temp = "";
byte[] _byte = source.getBytes("iso-8859-1");
_temp = new String(_byte, "GB18030");
source=_temp;
}
catch (Exception ex)
{
System.out.println(ex.toString());
}
return source;
}[/blue]
//当对象加入session时,将自动执行
public void valueBound(HttpSessionBindingEvent event) {
}
//当session对象中止时,将自动执行此函数
public void valueUnbound(HttpSessionBindingEvent event) {
if(con!=null)
close();//调用close方法
}
}
网页的代码如下:
<%@page contentType="text/html;charset=Gb2312" import="java.sql.*"%>
<html>
<head><title>jsp</title></head>
<body>
<jsp:useBean id="ConBean" scope="session" class="yysbgl.DBCon"/>
<%
java.sql.Statement stmt=null;
//String strSQL="select * from dlgh";
java.sql.Connection con=ConBean.getConnection();
stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
java.sql.ResultSet rs=stmt.executeQuery("select * from dlgh");
while(rs.next())
{
%>
<%=rs.getString("DLGH_GH")%>
<%
}
rs.close();
stmt.close();
ConBean.close();
%>
</body>
</html>
请问问题出在那里呢?