首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

TOMCAT 出错,又来麻烦大家了.该怎么解决

2011-12-27 
TOMCAT 出错,又来麻烦大家了.......2007-8-1418:03:23org.apache.jasper.runtime.PageContextImplrelease

TOMCAT 出错,又来麻烦大家了.......
2007-8-14   18:03:23   org.apache.jasper.runtime.PageContextImpl   release
警告:   Internal   error   flushing   the   buffer   in   release()

参照别人的代码拼凑的个JSP网页,控制台出现上述错误。
代码如下:麻烦大家帮找找问题,顺便看下有哪些不合理的地方?鞠躬谢谢~
----------------------------------
<%@   page   contentType= "text/html;   charset=gb2312 "%>
<%@   page   import= "java.sql.* "%>  
<%@   page   import= "java.util.* "%>
<%@   page   import= "java.util.Date "%>
<%@   page   import= "java.text.* "%>
<%@   include   file= "inc/conn.jsp "%>
<%
//request.setCharacterEncoding( "GB2312 ")   ;
%>
<html>
<head>
<title> </title>
</head>
<body>

<%
String   name=null;
name   =   (String)session.getAttribute( "name ");
if(name== " "||name==null)
{
out.print( "你必须登录才行噢 ");
%>
<center>
<a   href= "register.jsp "> 注册 </A>
<a   href= "login.jsp "> 登录 </a>
</center>
<%
}
else
{
out.print( "Hi,     "+   name   +   "   欢迎您回来! ");

%>

<a   href= "logout.jsp "> 注销 </a>
<hr   />
<br>
<br>
        <table   width= "760 "   border=1   cellspacing=0   bordercolordark=#CCCCCC   bordercolor=#ffffff   align= "center ">
            <tr>
                <center>
                    <td   width= "6% "> ID </td>
                    <td   width= "10% "> 姓名 </td>
                    <td   width= "9% "> 妮称 </td>
                    <td   width= "7% "> 密码 </td>
                    <td   width= "15% "> Email </td>
                    <td   width= "5% "> 性别 </td>
                    <td   width= "32% "> 登陆时间   </td>
                    <td   width= "16% "> IP </td>
                </center>
            </tr>


<%
try
{
String   sql= "select   *   from   staff   order   by   id   DESC ";  
ResultSet   rs=stmt.executeQuery(sql);  

int   intPageSize;   //一页显示的记录数
int   intRowCount;   //记录总数
int   intPageCount;   //总页数
int   intPage;   //待显示页码
String   strPage;
int   i;

//设置一页显示的记录数
intPageSize   =   10;



//取得待显示页码
strPage   =   request.getParameter( "pages ");
if(strPage==null){
//表明在QueryString中没有page这一个参数,此时显示第一页数据
intPage   =   1;
}
else
{
//将字符串转换成整型
intPage   =   Integer.parseInt(strPage);
if(intPage <1){   intPage   =   1;}
}
//获取记录总数  
rs.last();  
intRowCount   =   rs.getRow();  
//计算总页数
intPageCount   =(intRowCount+intPageSize-1)   /   intPageSize;

//调整待显示的页码
if(intPage> intPageCount)   intPage   =   intPageCount;
if(intPageCount> 0){
//将记录指针定位到待显示页的第一条记录上  
rs.absolute((intPage-1)   *   intPageSize+1);  
//显示数据  
i   =   0;  

//if   (rs.next()){
while(i <   intPageSize   &&   !rs.isAfterLast()){  


int   id=rs.getInt( "id ");
String   uuser=rs.getString( "name ");
String   nicheng=rs.getString( "nickname ");
String   pass=rs.getString( "password ");
String   email=rs.getString( "email ");
String   sex=rs.getString( "sex ");
String   time=rs.getString( "lasttime ");
String   ip=rs.getString( "ip ");

%>  

            <tr> <center>
                <td> <%=id%> </td>
                <td> <%=uuser%> </td>
                <td> <%=nicheng%> </td>
                <td> <%=pass%> </td>
                <td> <%=email%> </td>
                <td> <%=sex%> </td>
                <td> <%=time%> </td>
                <td> <%=ip%> </td>
</center>
            </tr>
<%
}
rs.next();  
i++;  
}
rs.close();  
stmt.close();  
conn.close();  
%>
</table>
<table   width= "760 "   border= "0 "   cellspacing= "0 "   cellpadding= "0 "   align= "center ">
                                <tr>  
                                    <td   align= "left "   width= "126 "> &nbsp;  
                                        <%out.print( "共 <font   color=red> "+intRowCount+ " </font> 个主题   <font   color=red> "+intPageSize+ " </font> /页   共 <font   color=red> "+intPageCount+ " </font> 页 ");%>
                                    当前第 <font   color=red> <%=intPage%> </font> 页   </td>


                                    <td   width= "634 "   height= "23 "   align= "right "> &nbsp;
        <%if(intPage <=1){%>
        首页
        <%}else{%>
                                        <a   href= "main.jsp?pages=1 "> 首页 </a>
<%}%>
                                        <%if(intPage> 1){%>
                                        <a   href= "main.jsp?pages= <%=intPage-1%> "> 上一页 </a>  
                                        <%}else{%>
                                        上一页  
                                        <%
                                }%>
                                        <%if(intPage <intPageCount){%>
                                        <a   href= "main.jsp?pages= <%=intPage+1%> "> 下一页 </a>  
                                        <%}else{%>
                                        下一页  
                                        <%
                                }%>
        <%if(intPageCount <=1||intPage==intPageCount){%>
        尾页
        <%}else{%>
                                        &nbsp; <a   href= "main.jsp?pages= <%=intPageCount%> "> 尾页 </a> &nbsp;
<%}%>
                                    </td>
                                </tr>
  </table>


<%
}
catch(Exception   e)
{
throw(e);
}
}
%>
</body>
</html>


------解决方案--------------------


代码的风格不好,开始的时候,一定要养成好的编程风格!要把视图和控制,还有模型分开,不要把jsp写入很多java代码,我帮你看了一下,修改如下:
<%@ page contentType= "text/html; charset=gb2312 "%>
<%@ page import= "java.sql.* "%>
<%@ page import= "java.util.* "%>
<%@ page import= "java.util.Date "%>
<%@ page import= "java.text.* "%>
<%@ include file= "inc/conn.jsp "%>
<%
//request.setCharacterEncoding( "GB2312 ") ;
%>
<html>
<head>
<title> </title>
</head>
<body>

<%
String name=null;
name = (String)session.getAttribute( "name ");
if(name== " "||name==null)
{
out.print( "你必须登录才行噢 ");
%>
<center>
<a href= "register.jsp "> 注册 </A>
<a href= "login.jsp "> 登录 </a>
</center>
<%
}
else
{
out.print( "Hi, "+ name + " 欢迎您回来! ");

%>

<a href= "logout.jsp "> 注销 </a>
<hr />
<br/>
<br/>
<table width= "760 " border=1 cellspacing=0 bordercolordark=#CCCCCC bordercolor=#ffffff align= "center ">
<tr align= "center ">

<td width= "6% "> ID </td>
<td width= "10% "> 姓名 </td>
<td width= "9% "> 妮称 </td>
<td width= "7% "> 密码 </td>
<td width= "15% "> Email </td>
<td width= "5% "> 性别 </td>
<td width= "32% "> 登陆时间 </td>
<td width= "16% "> IP </td>

</tr>


<%
try
{
Connection con = DriverManager.getConnection( "DatabaseURL ");
Statement stmt = con.createStatement();
String sql= "select * from staff order by id DESC ";
ResultSet rs=stmt.executeQuery(sql);

int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
String strPage;
int i;

//设置一页显示的记录数
intPageSize = 10;

//取得待显示页码
strPage = request.getParameter( "pages ");
if(strPage==null){
//表明在QueryString中没有page这一个参数,此时显示第一页数据
intPage = 1;
}
else
{
//将字符串转换成整型
intPage = Integer.parseInt(strPage);
if(intPage <1){ intPage = 1;}
}
//获取记录总数
rs.last();
intRowCount = rs.getRow();
//计算总页数
intPageCount =(intRowCount+intPageSize-1) / intPageSize;

//调整待显示的页码
if(intPage> intPageCount) intPage = intPageCount;
if(intPageCount> 0){
//将记录指针定位到待显示页的第一条记录上
rs.absolute((intPage-1) * intPageSize+1);
//显示数据
i = 0;

//if (rs.next()){
while(i < intPageSize && !rs.isAfterLast()){


int id=rs.getInt( "id ");
String uuser=rs.getString( "name ");
String nicheng=rs.getString( "nickname ");
String pass=rs.getString( "password ");
String email=rs.getString( "email ");
String sex=rs.getString( "sex ");
String time=rs.getString( "lasttime ");
String ip=rs.getString( "ip ");

%>

<tr align= "center ">
<td> <%=id%> </td>
<td> <%=uuser%> </td>
<td> <%=nicheng%> </td>
<td> <%=pass%> </td>
<td> <%=email%> </td>


<td> <%=sex%> </td>
<td> <%=time%> </td>
<td> <%=ip%> </td>

</tr>
<%
}
rs.next();
i++;
}
rs.close();
stmt.close();
con.close();
%>
</table>
<table width= "760 " border= "0 " cellspacing= "0 " cellpadding= "0 " align= "center ">
<tr>
<td align= "left " width= "126 "> &nbsp;
<%out.print( "共 <font color=red> "+intRowCount+ " </font> 个主题 <font color=red> "+intPageSize+ " </font> /页 共 <font color=red> "+intPageCount+ " </font> 页 ");%>
当前第 <font color=red> <%=intPage%> </font> 页 </td>
<td width= "634 " height= "23 " align= "right "> &nbsp;
<%if(intPage <=1){%>
首页
<%}else{%>
<a href= "main.jsp?pages=1 "> 首页 </a>
<%}%>
<%if(intPage> 1){%>
<a href= "main.jsp?pages= <%=intPage-1%> "> 上一页 </a>
<%}else{%>
上一页
<%
}%>
<%if(intPage <intPageCount){%>
<a href= "main.jsp?pages= <%=intPage+1%> "> 下一页 </a>
<%}else{%>
下一页
<%
}%>
<%if(intPageCount <=1||intPage==intPageCount){%>
尾页
<%}else{%>
&nbsp; <a href= "main.jsp?pages= <%=intPageCount%> "> 尾页 </a> &nbsp;
<%}%>
</td>
</tr>
</table>


<%
}
catch(Exception e)
{
throw(e);
}
}
%>
</body>
</html>

[解决办法]
不同的页用自己的连接对象,而且需要时再去创建,不用是关闭.
不要公共的使用一个conn.jsp里创建的conn对象.
不要把PHP的那种包含页的思想拿到JSP中.
[解决办法]
你发的太多了,把核心的发了就好了

热点排行