<%
          StringBuffer show = showLatestBulletin.showLatestBulletin();          
          out.print(show);
       %>
你没有输出,IE当然看不到
另外System.out.print()本身就是输出到控制台,好果要在IE中显示,返回给JSP就可以用out.print了

解决方案 »

  1.   

    <jsp:useBean id="showLatestBulletin" scope="page" class="EGAJavaBeans.Bulletin_showLatestBulletin">
              </jsp:useBean>
              
              <%showLatestBulletin.showLatestBulletin().toString())%>
    <%
    //显示错误
       if (showLatestBulletin.msg.length()>0)
          out.println(showLatestBulletin.msg);%>
    -------------------------------------
    我修正后的类.package EGAJavaBeans;import java.sql.*;
    import java.io.*;public class Bulletin_showLatestBulletin {    //错误信息记录
        public String msg;    public  Bulletin_showLatestBulletin() {
    msg = "";
        }    public StringBuffer showLatestBulletin()
        {
            StringBuffer buffer = new StringBuffer();

            try {
                Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                String url ="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=EGASystemDB";
                String username = "sa";
                String password = "123";
                Connection conn = DriverManager.getConnection(url, username,password);
                Statement stmt =  conn.createStatement();            String strsql = "select * from EGA_Bulletin";
                ResultSet rs = stmt.executeQuery(strsql);            try{
                    buffer.append("<table width=100%>");
                    buffer.append("<tr>");
                    buffer.append("<th>" + "公告名");
                    buffer.append("</tr>");
                    while (rs.next()) {
                        buffer.append("<tr>");
                        buffer.append("<td>" + rs.getString(2) + "</td>");
                        buffer.append("</tr>");
                    }
                  
                    buffer.append("</table>");
                }catch(Exception e3)
                {
                   msg = "数据读取出错!!出错信息为:<br>" + e3.getMessage() ;
                }     //关闭资源
                rs.close();
                stmt.close();
                conn.close();
            }
            catch (Exception e2) {
                msg +="SQL语句提交出错!出错信息为"+e2.getMessage();
                System.out.print("SQL语句提交出错!");
            }        return buffer;
            
        }        
        
       
    }