页面头一次显示正常,但一刷新就出错org.apache.jasper.JasperException

yuanz62 2003-01-13 02:24:11
页面头一次显示正常,但一刷新就出错org.apache.jasper.JasperException
页面代码如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page errorPage="bookstoreErr.jsp" import="java.sql.*,java.io.*,java.text.*,java.util.*,mybeans.bookstore.*"%>
<jsp:useBean id="connPool" scope="application" class="mybeans.bookstore.ConnPool">
<jsp:setProperty name="connPool" property="driverName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
<jsp:setProperty name="connPool" property="jdbcURL" value="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=bookstore"/>
<jsp:setProperty name="connPool" property="username" value="sa"/>
<jsp:setProperty name="connPool" property="password" value="1108"/>
<jsp:setProperty name="connPool" property="connectionSwitch" value="on"/>
</jsp:useBean>
<jsp:useBean id="sqlbridge" scope="page" class="mybeans.bookstore.SqlBridge">
<jsp:setProperty name="sqlbridge" property="connPool" value="<%=connPool%>"/>
<jsp:setProperty name="sqlbridge" property="connectionSwitch" value="on"/>
</jsp:useBean>
<script language="javascript">
<!--
function indexFormSubmit(url)
{
document.indexForm.action=url;
document.indexForm.submit();
}
//-->
</script>
<html>
<head>
<title>网上图书定购系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<div align="center">
<p> </p>
<p> </p>
<p> </p>
<p><font size="+2" color="#990000">欢迎使用网上图书订购系统</font></p>
<form name="indexForm" method="post" action="bookorder.jsp">
<table width="75%" border="0">
<tr align="center" bgcolor="004d99">
<td colspan="4"><font color="#FFFFFF">帐号</font>
<input type="text" name="id" size="10" maxlength="8">
<font color="#FFFFFF">密码</font>
<input type="text" name="password" maxlength="8" size="10">
<input type="submit" name="Submit" value="确定">
</td>
</tr>
<tr align="center">
<td colspan="4">  </td>
</tr>
<tr>
<td width="40%" height="36"><a href="memberRegister.html">加入会员</a>(享受八折优惠)</td>
<td width="27%" height="36"><a href="javascript:indexFormSubmit('queryMemberData.jsp')">会员资料查询</a></td>
<td width="30%" height="36"><a href="javascript:indexFormSubmit('SystemAdmin.jsp')">系统维护</a></td>
<td width="3%" height="36"> </td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
</table>
</form>
<p> </p>
</div>
</body>
</html>
...全文
86 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
rushishuo 2003-01-22
  • 打赏
  • 举报
回复
自己心细点,仔细看看
hanty 2003-01-22
  • 打赏
  • 举报
回复
<jsp:setProperty name="sqlbridge" property="connectionSwitch" value="on"/>
connectionSwitch这个你在那里定义着呢??
是没有定义的问题
shuhw 2003-01-17
  • 打赏
  • 举报
回复
connectionSwitch你没有定义
yuanz62 2003-01-13
  • 打赏
  • 举报
回复
我试过,但不行。
我发现只要将
<jsp:useBean id="sqlbridge" scope="page" class="mybeans.bookstore.SqlBridge">
<jsp:setProperty name="sqlbridge" property="connPool" value="<%=connPool%>"/>
<jsp:setProperty name="sqlbridge" property="connectionSwitch" value="on"/>
</jsp:useBean>
中的
<jsp:setProperty name="sqlbridge" property="connectionSwitch" value="on"/>
这行去掉后就好了,可这是怎么回事呢?
我的SqlBridge.java程序如下:
package mybeans.bookstore;
import java.lang.*;
import java.sql.*;
import javax.swing.*;
import javax.servlet.*;

public class SqlBridge{
private ConnPool connPool;
private Connection conn;
private ResultSet rs;
private ResultSetMetaData rsmd;
private Statement stmt;
private String driverName;
private String jdbcURL;
private String username;
private String password;


public SqlBridge(){
conn=null;
rs=null;
rsmd=null;
stmt=null;
}

//link to the database
public void openDB(ConnPool pool)
throws SQLException{
if(conn!=null&&!conn.isClosed())
throw new SQLException("The connection has been established already.");
if(pool==null)
throw new SQLException("The connection pool can not be found.");
clearResult();
connPool=pool;
conn=connPool.getConnection();
}

public void openDB(String drvName,String URL,String uname,String passwd)
throws SQLException{
if(conn!=null&&!conn.isClosed())
throw new SQLException("The connection has been established already.");
clearResult();
try
{
Class.forName(drvName);
}
catch(ClassNotFoundException ex)
{
throw new SQLException(ex.toString());
}
conn=DriverManager.getConnection(URL,uname,passwd);
}



private void clearResult() throws SQLException{
if (rs!=null) rs.close();
rs=null;
if(stmt!=null) stmt.close();
stmt=null;
rsmd=null;
}
public int execSQL(String sqlStmt) throws SQLException{
.....
}
protected Object getField(int column,boolean convertToString){
......
}
public void closeDB() throws SQLException{
clearResult();
if (connPool!=null)
{
connPool.returnConnection();
connPool=null;
}
else
{
if(conn==null)
throw new SQLException("This connection has been closed already!");
if(conn.isClosed())
throw new SQLException("This connection has been closed.");
conn.close();
}
conn=null;
}

//method for JavaBean
public void setConnectionSwitch(String on_off)
throws ServletException{
try{
if (on_off.equalsIgnoreCase("ON"))
{
if(connPool==null)
openDB(driverName,jdbcURL,username,password);
else
openDB(connPool);
}
else if(on_off.equalsIgnoreCase("OFF"))
closeDB();
}
catch(SQLException ex){
throw new ServletException(ex.toString());
}
}

public void setDriverName(String drvName)
{
driverName=drvName;
}

public void setJdbcURL(String URL)
{
jdbcURL=URL;
}

public void setUsername(String uname)
{
username=uname;
}

public void setPassword(String pwd)
{
password=pwd;
}

public void setConnPool(ConnPool pool){
connPool=pool;
}
不好意思,代码贴的长了,请大伙帮我看看,初学,谢谢各位了,每帖必结
希偌 2003-01-13
  • 打赏
  • 举报
回复
记得重新启动服务器
希偌 2003-01-13
  • 打赏
  • 举报
回复
我怀疑是cache问题
你把tomcat下的work目录删除,看看直接启动是否正常

81,090

社区成员

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

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