你把你另一个jsp和bean贴出来,或许能帮你找到问题的原因

解决方案 »

  1.   

    另外一个showuser.jsp:
    <%@page language="java"import ="java.sql.*,java.io.*,java.util.*"%>
    <%@page contentType="text/HTML;charset=gb2312"%>
    <jsp:useBean id="testBean" class="mypackage.gx"scope="session"/>
    <html>
    <head>
    <title>员工信息表</title>
    <meta http-equiv="Refresh" content="10;URL=../mis/showuser.jsp">
    <%
    StringBuffer userInfo=new StringBuffer();
    StringBuffer pageInfo=new StringBuffer();
    int pageSize=10;//定义一页显示的记录数

    String paraPage=request.getParameter("page");//获得当前要请求的页
    int currentPage=1;
    try{currentPage=Integer.parseInt(paraPage);
    }catch(Exception e)
    {currentPage=1;
    }
    ResultSet rs=testBean.executeQuery("select * from users_inf");
    rs.last();//指针置于底
    int totalUser=rs.getRow();//获得总的记录数
    int pageCount=(int)Math.ceil((float)totalUser/(float)pageSize);//计算出总页数:ceil()是个除法运算
    int i=1;
    rs.absolute((currentPage-1)*pageSize+1);//把指针放在要显示的第一个数据
    //把结果放到变量userInfo中

    while(i<=pageSize)
    {
    userInfo.append("<tr bgcolor=#ffffff>\n");
    userInfo.append("<td align=center>"+((currentPage-1)*pageSize+i)+"</td>");
    userInfo.append("<td align=center>"+"<a href='sendmessage.jsp?user_id="+rs.getString("user_id")+"'>"+rs.getString("user_name")+"</a>"+"</td>");
    //userInfo.append("<td>"+rs.getString("user_password")+"</td>");
    userInfo.append("<td>"+rs.getString("user_realname")+"</td>");
    userInfo.append("</tr>");
    if(!rs.next())//假如到底就推出循环
    break;
    i++;

    }
    //关闭数据库连接
    rs.close();
    /*把要显示的信息放到变量pageInfo中
    把显示翻页的信息放到变量pageInfo中*/
    pageInfo.append("第"+currentPage+"页共"+pageCount+"页共"+totalUser+"用户");//信息
    if(currentPage>1)//在当前页大于一的页有向前翻页的连接,否则没有
    pageInfo.append("<a href='showuser.jsp?page="+(currentPage-1)+"'>&lt;&lt;上一页</a>");
    else
    pageInfo.append("&lt;&lt;上一页");
    if(currentPage<pageCount)
    pageInfo.append("<a href ='showuser.jsp?page="+(currentPage+1)+"'>&gt;&gt;下一页</a>");
    else
    pageInfo.append("下一页&gt;&gt;");

    //显示结果
    %>
    </head>
    <body>
    <a href="general.jsp">离开通讯模块<a>
    <table width="50%" border="0" align="center" cellpadding=5 cellspacing=1 bgcolor=#000000>
    <tr align="center"bgcolor=#cccccc>
    <td width="20%">编号</td>
    <td width="40%">用户名称</td>
    <td width="40%">真实姓名</td>
    </tr>
    <%=userInfo%>
    </table>
    <table width="80%" border="0" align="center">
    <tr>
    <td align=right><%=pageInfo%>
    </td>
    </tr>
    </table>
    <%
    ResultSet rs2=testBean.executeQuery("select * from message_inf where user_id='"+session.getValue("id")+"' and isview='0'");
    if(rs2.next())
    {
    out.print("你有新的留言");
    %>
    <a href="showmessage.jsp"><img src="mail.gif"></a>



    <%
    }
    try
    { rs2.close();
    testBean.closeConn();
    testBean.closeStmt();
    }catch(Exception e){System.err.println(e);}
    %>
    <center><h3>*****点击用户名称可以给该用户发消息******</h3></center>
    <%@ include file="last.html"%>
    </body>
    </html>
    数据库bean:
    package mypackage;
    import java.sql.*;
    public class gx{
    String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";//数据库驱动
    //数据库连接字符串
    String sConnStr="jdbc:odbc:firm";
    private Connection conn=null;
    private Statement stmt=null;
    private ResultSet rs=null;
    //构造函数
    public gx(){
    try{
    Class.forName(sDBDriver);//加载数据库驱动程序
    }
    catch (java.lang.ClassNotFoundException e){
    System.err.println("firm()"+e.getMessage());
    }//抛出例外
    }
    //定义executeQuery()函数
    public ResultSet executeQuery(String sql){
    rs=null;
    try{
    conn=DriverManager.getConnection(sConnStr,"sa","admin");
    stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    rs=stmt.executeQuery(sql);

    }
    catch(SQLException e){
    System.err.println("aq.executeQuery:"+e.getMessage());
    }
    return rs;
    }
    //定义executeUpdate()函数
    public void executeUpdate(String sql){
    stmt=null;
    rs=null;
    try{
    conn=DriverManager.getConnection(sConnStr,"sa","admin");
    stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    stmt.executeUpdate(sql);
    stmt.close();
    conn.close();
    }
    catch(SQLException e){
    System.err.println("aq.executeUpdate:"+e.getMessage());
    }
    }
    //定义close()为关闭程序
      public void closeStmt(){
        try{
          stmt.close();
         }
        catch(SQLException e){
          e.printStackTrace();
         }
      }
      public void closeConn(){
        try{
          conn.close();
         }
        catch(SQLException e){
          e.printStackTrace();
         }
      }
    }
    谢谢你, Leemaasn(他这家伙不怀好意 :P)
      

  2.   

    我把它报错的准确写出来:message description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: [Microsoft][ODBC SQL Server Driver]无效的描述符索引高手帮忙啊!
    我的bean在其他的程序里可以运行,但是到了这个jsp程序里就有问题了!
    是这样的:
    我的jsp程序:
    <%@page language="java"import ="java.sql.*"%>
    <%@page contentType="text/HTML;charset=gb2312"%>
    <jsp:useBean id="testBean" class = "mypackage.gx"scope= "session"/>
    <%


    StringBuffer userInfo=new StringBuffer();
    StringBuffer pageInfo=new StringBuffer();
    int pageSize=10;//定义一页显示的记录数
    String paraPage=request.getParameter("page");//获得当前要请求的页
    int currentPage=1;
    try{currentPage=Integer.parseInt(paraPage);
    }catch(Exception e)
    {currentPage=1;
    }
    ResultSet rs=testBean.executeQuery("select * from news_inf");
    rs.last();//指针置于底
    int totalUser=rs.getRow();//获得总的记录数
    int pageCount=(int)Math.ceil((float)totalUser/(float)pageSize);//计算出总页数:ceil()是个除法运算
    int i=1;
    rs.absolute((currentPage-1)*pageSize+1);

    while(i<=pageSize)
    {
    userInfo.append("<tr bgcolor=#ffffff>\n");
    userInfo.append("<td align=center>"+((currentPage-1)*pageSize+i)+"</td>");

    userInfo.append("<td>"+rs.getString("posttime")+"</td>");
    userInfo.append("<td>"+rs.getString("news_title")+"</td>"); userInfo.append("<td>"+rs.getString("news_content")+"</td>");
    userInfo.append("<td><a href='deletenews_ok.jsp?news_id="+rs.getString("news_id")+"'>删除</a></td>");
    userInfo.append("</tr>");
    if(!rs.next())//假如到底就推出循环
    break;
    i++;
    }
    //关闭数据库连接
    try
    {
    rs.close();
    testBean.closeConn();
    testBean.closeStmt();
    }catch(Exception e){System.err.println(e);}
    /*把要显示的信息放到变量pageInfo中
    把显示翻页的信息放到变量pageInfo中*/
    pageInfo.append("第"+currentPage+"页共"+pageCount+"页共"+totalUser+"条新闻");//信息
    if(currentPage>1)//在当前页大于一的页有向前翻页的连接,否则没有
    pageInfo.append("<a href='shownews.jsp?page="+(currentPage-1)+"'>&lt;&lt;上一页</a>");
    else
    pageInfo.append("&lt;&lt;上一页");
    if(currentPage<pageCount)
    pageInfo.append("<a href ='shownews.jsp?page="+(currentPage+1)+"'>&gt;&gt;下一页</a>");
    else
    pageInfo.append("下一页&gt;&gt;");
    //显示结果
    %><html>
    <head>
    <title>新闻</title>
    </head>
    <body>
    <table width="80%" border="0" align="center" cellpadding=5 cellspacing=1 bgcolor=#000000>
    <tr align="center"bgcolor=#cccccc>
    <td width="7%">编号</td>
    <td width="20%">发布时间</td>
    <td width="23%">新闻名称</td>
    <td width="43%">新闻内容</td><td width="7%">操作</td>
    </tr>
    <%=userInfo%>
    </table>
    <table width="80%" border="0" align="center">
    <tr>
    <td align=right><%=pageInfo%>
    </td>
    </tr>
    </table>
    <a href="addnews.html">添加新闻</a>
    </body>
    </html>
    我在里面把:userInfo.append("<td><a href='deletenews_ok.jsp?news_id="+rs.getString("news_id")+"'>删除</a></td>");改成:userInfo.append("<td><a href='deletenews_ok.jsp?'>删除</a></td>");
    结果就没有问题了!大家看是什么问题呢!我瞑思苦想还是想不通啊!!
      

  3.   

    肯定有的啊!!我能确定!!谢谢:wchar(寻找平淡)
      

  4.   

    我晓得原因了!
    是MS SQL SERVER的问题!他妈的换成了访问另外的一个数据库(professional版本)的结果就没有问题了!现在我把我的MS SQL SERVER删了,结果再装个人版,提示说不能装!我吐血!
      

  5.   

    要把sql在注册表内的信息X光才行