为什么我的网页连续刷新十多次就会出错呢???? null错误有什么地方出现null值了是不是你连接没关掉,连接池满了哦? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你是每此刷新的errlog或outlog里都有以上错误,还是弟10次才有?如果是第10次才有, 你用到数据库连接吗? 有的话, 可能就是没有释放数据库连接! 每次数据库操作完毕,在Finally里面请关闭Connection,或者释放回连接池 你有没有用session?如果用了可能会话过期了 很明显是index.jsp的第21行出现了NullPointerException看看是哪个对象为null了而调用了其方法每次刷新都会执行服务端的代码将index.jsp贴出来!!!! <%/*作者:黄圣兵修改:翟耀纲修改描述:添加热点新闻的链接日期:2004-1-19*/%><%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %><%@ include file="inc/connlogin2.jsp"%><%ResultSet rs;String sql;sql="select * from setup ";rs=conn.executeQuery(sql);rs.next();String stop,StopMessage,Title,Description,Keywords,SendMail,Emailadd,BanStr;int Count,CountType;stop=rs.getString("stop").trim();StopMessage=rs.getString("StopMessage");Title=rs.getString("title");Description=rs.getString("description");Keywords=rs.getString("keywords");SendMail=rs.getString("sendmail");Emailadd=rs.getString("email");BanStr=rs.getString("BanStr");Count=rs.getInt("count");CountType=rs.getInt("counttype");if (stop.equals("1") ) {out.print(StopMessage); return;} %><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><META content="<%=Description%>"name=DESCRIPTION><META content=<%=Keywords%> name=keywords><title><%=Title%></title><link href="main.css" rel="stylesheet" type="text/css"><script language="javascript" src="inc/fly.js" ></script><%rs.close();java.sql.ResultSet sqlRst; //结果集对象sqlRst=conn.executeQuery("select * from pop_win where is_use='1' order by pop_id desc");while(sqlRst.next()){%><script>window.open ("popwin.jsp", "newwindow", "height=<%=sqlRst.getString("win_height")%>, width=<%=sqlRst.getString("win_height")%>, top=0, left=0, toolbar=no,menubar=no, scrollbars=no, resizable=no,location=no, status=no")</script><%}sqlRst.close();%></head><%java.sql.ResultSet sqlRst_fly; //结果集对象sqlRst_fly=conn.executeQuery("select * from fly_pic where is_use='1' order by link_id desc");if(sqlRst_fly.next()){%><body onLoad="floater()" bgcolor=#cccccc><div id=floater style="HEIGHT: 0px; POSITION: absolute; WIDTH: 0px; left: 185px; top: 73px; z-index:100" ><a href= target=_blank><img border=0 src=admin/flypic/pic/<%=sqlRst_fly.getString("pic_path")%> height="<%=sqlRst_fly.getString("pic_height")%>" width="<%=sqlRst_fly.getString("pic_width")%>"></a> </div><%}else{%><body bgcolor=#cccccc><%}sqlRst_fly.close();%><%@ include file="title.jsp"%><table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr valign="top"> <td width="180" class="box1"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="box1-line-4"><img src="images/xxi.jpg" width="180" height="19" border="0"></td> </tr> <tr> <td bgcolor="#E7E3E7" class="box1-line-4"><table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td> <img src="images/arrok.gif" width="10" height="11"><a href="cgs.jsp">车辆及驾驶员管理业务<br> </a> <%@ include file="inc/bszn_bar.jsp"%> </td> </tr> </table></td> </tr> <tr> <td bgcolor="#E7E3E7" class="box1-line-4"><table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td><%@ include file="inc/bszn_list.jsp"%> </td> </tr> </table></td> </tr> <tr> <td class="box1-line-4"><img src="images/arr5.gif" width="179" height="18" border="0"></td> </tr> <tr> <td align="center" class="box1-line-4"><%@ include file="inc/pic_link_list.jsp"%> </td> </tr> <tr> <td><div align="center"> <script src="http://61.151.248.125/mystat.asp?style=counter&username=sitelogdemo"></script></div></td> </tr> </table> </td> <td width="10"><img src="images/spacer.gif" width="10" height="10"></td> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td background="images/do.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><img src="images/arr2.gif" width="132" height="39" border="0"></td> <td align="right"><font color="#333333"><a href="news.jsp">>>更多</a></font></td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="10"> <%ResultSet rs_hot=conn.executeQuery("select * from info_details where mod_id=56 and not (attachment is null) and status='3' and rownum<=1 order by info_id desc"); while(rs_hot.next()) { String attachment; attachment=rs_hot.getString("attachment"); %> <tr> <td width="130" align="center" class="box2-1"> <img src="admin/news/pic/<%=attachment%>" width="160" height="120"> </td> <td align="left" valign="top" class="box2-2"><a href='show_news.jsp?info_id=<%=rs_hot.getString("info_id")%>'><strong><%=rs_hot.getString("subject")%></strong><br><br> <%=getcontent(conn.clob2string(rs_hot.getClob("content2"))).substring(0,80)%> ...</a></td> </tr><%} rs_hot.close();%> </table></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="10"> <tr> <td class="newslist"></td> </tr> </table> <%@ include file="inc/news_list.jsp"%> </td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td align="left"> <jsp:include page="inc/show_ad.jsp" > <jsp:param name="mod_id" value="99"/> <jsp:param name="width" value="350"/> <jsp:param name="height" value="35"/> </jsp:include> </td> </tr> </table></td> </tr> <tr> <td background="images/do.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><img src="images/arr1.gif" width="132" height="39" border="0"></td> <td align="right"><font color="#333333"><a href="doc.jsp">>>更多</a></font></td> </tr> </table></td> </tr> <tr> <td class="newslist"><table width="100%" border="0" cellspacing="0" cellpadding="10"> <tr> <td></td> </tr> </table></td> </tr> <tr> <td><%@ include file="inc/law_list.jsp"%> </td> </tr> </table></td> <td width="180" bgcolor="#42AAF7"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ADCBFF"> <tr> <td><img src="images/b1.gif" width="100" height="22" border="0"></td> <td align="right"><FONT color="white">more</font></td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td height="200"><marquee onMouseOut=this.start() onMouseOver=this.stop() border="0" direction="up" scrolldelay="75" scrollamount="1" width="170" height="200"> <%@ include file="inc/bbs_list.jsp"%> </marquee></td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ADCBFF"> <tr> <td><img src="images/arr8.gif" width="100" height="22" border="0"></td> <td align="right"> </td> </tr> </table></td> </tr> <tr> <td> <table width="100%" border="0" cellspacing="0" cellpadding="5"><form action=search.jsp name=search method="post"> <tr> <td>搜索: <input type="text" name="keyword" value="输入关键字" size="12"> <br> <span style="text-decoration:none;"> <select style="font-family:宋体; font-size:9pt; background-color:white; border-width:1px; border-color:yellow; border-style:solid;" size="1" name="type"> <option value="news.jsp" selected>新闻动态</option><option value="doc.jsp" >政策法规</option><option value="download.jsp" >常用表格</option><option value="cljz.jsp" >车驾管理</option><option value="bszn.jsp" >办事指南</option> </select> <br> </span><img src="images/chaxun.gif" width="46" height="17" border="0"onclick="search.action=type.value;search.submit()"> </td> </tr></form> </table></td> </tr> <tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ADCBFF"> <tr> <td><img src="images/arr3.gif" width="100" height="22" border="0" onclick="search.submit()"></td> <td align="right"><FONT color="white">more</font></td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td></td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ADCBFF"> <tr> <td><img src="images/arr6.gif" width="100" height="22" border="0"></td> <td align="right"> </td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td><%@ include file="inc/link_list.jsp"%> </td> </tr> </table></td> </tr> <tr> <td> </td> </tr> </table></td> </tr></table><%@ include file="inc/copyright.jsp"%> 你的哪个页面肯定从其它也面得到了数据,然后刷新后就null拉. 對數據庫操作完要rs.close();con.close(); ......从代码看没有一句错误处理的代码......正是老外所说的"典型的中国人的程序",也是中国软件被瞧不起的原因........最基本的要用一个不是才定义的对象的方法时,先判断是否是null,并做相应处理include 了inc/connlogin2.jsp,有可能错误在其中也不一定conn是connlogin2.jsp中定义的,可能是其有问题?想想表setup中要没有记录会是什么情况?????写代码要考虑所有可能的情况,并养成良好的错误处理习惯!!!! 或者你在页面之间,用到session传值,或其它方式传值,没有很好的控制。第二个,就是在连库文件中没很好的控制连接。 你在include中怎么创建的连接?又在include中怎么关闭的连接?能给贴出来看看吗? 估计不是资源耗尽的问题,如果是读写文件,那就肯定是指针下移的无法!或者你本身不支持回滚,你却硬要回滚就会造成这样如果是读取数据库,那这个问题很容易解释了,简单没有判断有无结果就NEXT,大概道理就是读取了没有的数据造成的,很容易理解,看看自己的循环,应该可以找到问题的根源 jpa有实体,怎么生成数据库表呢? wap里面怎么设置文件链接为下载的方式而不是直接打开 请问在linux上怎么部署两个以上的网站啊 求助js改写成java类 急,求救! CSDN主页中的厂商专区的菜单能是怎么实现的? 下载对话框的问题 如何传递两个参数,传递一个参数我知道,<a href="huifu.jsp?bh=<%=bh%>">回复</a>,如何在传递一个id参数呢? Calendar的日期计算问题? 很奇怪的问题?各位进来看一下. 那位看看我这个简短的JSP程序的问题 JDBC 通过存储过程操作 ORACLE临时表的问题
如果是第10次才有, 你用到数据库连接吗? 有的话, 可能就是没有释放数据库连接!
看看是哪个对象为null了而调用了其方法
每次刷新都会执行服务端的代码将index.jsp贴出来!!!!
/*
作者:黄圣兵
修改:翟耀纲
修改描述:添加热点新闻的链接
日期:2004-1-19
*/
%><%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
<%@ include file="inc/connlogin2.jsp"%><%
ResultSet rs;
String sql;
sql="select * from setup ";
rs=conn.executeQuery(sql);
rs.next();
String stop,StopMessage,Title,Description,Keywords,SendMail,Emailadd,BanStr;
int Count,CountType;
stop=rs.getString("stop").trim();
StopMessage=rs.getString("StopMessage");
Title=rs.getString("title");
Description=rs.getString("description");
Keywords=rs.getString("keywords");
SendMail=rs.getString("sendmail");
Emailadd=rs.getString("email");
BanStr=rs.getString("BanStr");
Count=rs.getInt("count");
CountType=rs.getInt("counttype");
if (stop.equals("1") )
{out.print(StopMessage);
return;} %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META content="<%=Description%>"
name=DESCRIPTION>
<META content=<%=Keywords%> name=keywords>
<title><%=Title%></title>
<link href="main.css" rel="stylesheet" type="text/css">
<script language="javascript" src="inc/fly.js" ></script>
<%
rs.close();
java.sql.ResultSet sqlRst; //结果集对象
sqlRst=conn.executeQuery("select * from pop_win where is_use='1' order by pop_id desc");
while(sqlRst.next())
{%>
<script>
window.open ("popwin.jsp", "newwindow", "height=<%=sqlRst.getString("win_height")%>, width=<%=sqlRst.getString("win_height")%>, top=0, left=0, toolbar=no,menubar=no, scrollbars=no, resizable=no,location=no, status=no")
</script>
<%}
sqlRst.close();%>
</head>
<%java.sql.ResultSet sqlRst_fly; //结果集对象sqlRst_fly=conn.executeQuery("select * from fly_pic where is_use='1' order by link_id desc");
if(sqlRst_fly.next())
{%>
<body onLoad="floater()" bgcolor=#cccccc>
<div id=floater style="HEIGHT: 0px; POSITION: absolute; WIDTH: 0px; left: 185px; top: 73px; z-index:100" ><a href= target=_blank><img border=0 src=admin/flypic/pic/<%=sqlRst_fly.getString("pic_path")%> height="<%=sqlRst_fly.getString("pic_height")%>" width="<%=sqlRst_fly.getString("pic_width")%>"></a>
</div><%}
else{%>
<body bgcolor=#cccccc>
<%}
sqlRst_fly.close();%>
<%@ include file="title.jsp"%>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr valign="top">
<td width="180" class="box1"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="box1-line-4"><img src="images/xxi.jpg" width="180" height="19" border="0"></td>
</tr>
<tr>
<td bgcolor="#E7E3E7" class="box1-line-4"><table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
</a>
<%@ include file="inc/bszn_bar.jsp"%>
</td>
</tr>
</table></td>
</tr>
<tr>
<td bgcolor="#E7E3E7" class="box1-line-4"><table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td><%@ include file="inc/bszn_list.jsp"%> </td>
</tr>
</table></td>
</tr>
<tr>
<td class="box1-line-4"><img src="images/arr5.gif" width="179" height="18" border="0"></td>
</tr>
<tr>
<td align="center" class="box1-line-4"><%@ include file="inc/pic_link_list.jsp"%>
</td>
</tr>
<tr>
<td><div align="center"> <script src="http://61.151.248.125/mystat.asp?style=counter&username=sitelogdemo"></script></div></td>
</tr>
</table>
</td>
<td width="10"><img src="images/spacer.gif" width="10" height="10"></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/do.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/arr2.gif" width="132" height="39" border="0"></td>
<td align="right"><font color="#333333"><a href="news.jsp">>>更多</a></font></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="10">
<%ResultSet rs_hot=conn.executeQuery("select * from info_details where mod_id=56 and not (attachment is null) and status='3' and rownum<=1 order by info_id desc");
while(rs_hot.next())
{ String attachment;
attachment=rs_hot.getString("attachment");
%>
<tr>
<td width="130" align="center" class="box2-1"> <img src="admin/news/pic/<%=attachment%>" width="160" height="120">
</td>
<td align="left" valign="top" class="box2-2"><a href='show_news.jsp?info_id=<%=rs_hot.getString("info_id")%>'><strong><%=rs_hot.getString("subject")%></strong><br><br>
<%=getcontent(conn.clob2string(rs_hot.getClob("content2"))).substring(0,80)%> ...</a></td>
</tr><%}
rs_hot.close();%>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
<td class="newslist"></td>
</tr>
</table>
<%@ include file="inc/news_list.jsp"%>
</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td align="left"> <jsp:include page="inc/show_ad.jsp" >
<jsp:param name="mod_id" value="99"/>
<jsp:param name="width" value="350"/>
<jsp:param name="height" value="35"/>
</jsp:include> </td>
</tr>
</table></td>
</tr>
<tr>
<td background="images/do.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/arr1.gif" width="132" height="39" border="0"></td>
<td align="right"><font color="#333333"><a href="doc.jsp">>>更多</a></font></td>
</tr>
</table></td>
</tr>
<tr>
<td class="newslist"><table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
<td></td>
</tr>
</table></td>
</tr>
<tr>
<td><%@ include file="inc/law_list.jsp"%> </td>
</tr>
</table></td>
<td width="180" bgcolor="#42AAF7"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ADCBFF">
<tr>
<td><img src="images/b1.gif" width="100" height="22" border="0"></td>
<td align="right"><FONT color="white">more</font></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td height="200"><marquee onMouseOut=this.start() onMouseOver=this.stop() border="0" direction="up" scrolldelay="75" scrollamount="1" width="170" height="200"> <%@ include file="inc/bbs_list.jsp"%>
</marquee></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ADCBFF">
<tr>
<td><img src="images/arr8.gif" width="100" height="22" border="0"></td>
<td align="right"> </td>
</tr>
</table></td>
</tr>
<tr>
<td> <table width="100%" border="0" cellspacing="0" cellpadding="5">
<form action=search.jsp name=search method="post">
<tr>
<td>搜索:
<input type="text" name="keyword" value="输入关键字" size="12">
<br> <span style="text-decoration:none;">
<select style="font-family:宋体; font-size:9pt; background-color:white; border-width:1px; border-color:yellow; border-style:solid;" size="1" name="type">
<option value="news.jsp" selected>新闻动态</option>
<option value="doc.jsp" >政策法规</option>
<option value="download.jsp" >常用表格</option>
<option value="cljz.jsp" >车驾管理</option>
<option value="bszn.jsp" >办事指南</option>
</select>
<br>
</span><img src="images/chaxun.gif" width="46" height="17" border="0"onclick="search.action=type.value;search.submit()">
</td>
</tr></form>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ADCBFF">
<tr>
<td><img src="images/arr3.gif" width="100" height="22" border="0" onclick="search.submit()"></td>
<td align="right"><FONT color="white">more</font></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#ADCBFF">
<tr>
<td><img src="images/arr6.gif" width="100" height="22" border="0"></td>
<td align="right"> </td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td><%@ include file="inc/link_list.jsp"%> </td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table><%@ include file="inc/copyright.jsp"%>
conn是connlogin2.jsp中定义的,可能是其有问题?想想表setup中要没有记录会是什么情况?????
写代码要考虑所有可能的情况,并养成良好的错误处理习惯!!!!
第二个,就是在连库文件中没很好的控制连接。
或者你本身不支持回滚,你却硬要回滚就会造成这样如果是读取数据库,那这个问题很容易解释了,简单没有判断有无结果就NEXT,大概道理就是读取了没有的数据造成的,很容易理解,看看自己的循环,应该可以找到问题的根源