Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Servlet/JSP/JSF/JavaFX Script
打印话题 寄给朋友 订阅主题 |
作者 | 各位大虾帮帮忙 |
J2EE1982
发贴: 7 |
于 2005-08-18 17:57
<%@ page import = "java.sql.*" %> <%@ page import = "com.Mysql" %> <% Mysql mysql = new Mysql(); int intPage; int currentPage = 1; int PageNumbers = 10; if(request.getParameter("page")!=null && request.getParameter("page")!="") intPage = Integer.parseInt(request.getParameter("page")); else intPage = 1; int totalRecord = 0; ResultSet counters = mysql.executeQuery("select count as cnt from stsNews"); if(counters.next()) { totalRecord = counters.getInt("cnt"); } %> <html> <head><title>新闻发布系统1.0版</title> <LINK href="css/sts.css" rel=stylesheet type=text/css> </head> <body> <div align="center" style="width: 901; height: 21"> <%@ include file="inc/top.jsp" %> <br> <table border = 0 width="505" cellspacing="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111"> <tr bgcolor="#00ff00"><td width="505" colspan=2><img src="pic\qq.gif">新闻标题</td></tr> <% if(session.getValue("name")==null || session.getValue("name")=="") { %> <% String strSQL = "select id,title from stsNews order by id desc"; ResultSet rs = mysql.executeQuery(strSQL); int i=0; while(rs.next()) { if(i >= (intPage-1)*PageNumbers && i < intPage*PageNumbers) { String id = rs.getString("id"); String title = rs.getString("title"); out.print("<tr bgcolor = \"#00dc45\"><td width=300 valign=\"top\"><img src=\"pic\\gb.gif\"><a href=\"view.jsp?id="+id+"\">"+ title +"</a></td><td></td></tr>"); } i++; } %> </table> </div> <% rs.close(); } else { %> <% String strSQL = "select id,title from stsNews order by id desc"; ResultSet rs = mysql.executeQuery(strSQL); int i=0; while(rs.next()) { if(i >= (intPage-1)*PageNumbers && i < intPage*PageNumbers) { String id = rs.getString("id"); String title = rs.getString("title"); out.print("<tr bgcolor = \"#00dc45\"><td valign=\"top\" width=\"90%\"><img src=\"pic\\gb.gif\"><a href=\"view.jsp?id="+id+"\">"+ title +"</a></td><td width=\"10%\"><a href=\"delete.jsp?id="+id+"\">删除</a></td></tr>"); } i++; } %> </table> <% rs.close(); } %> <br> <div align="center" >新闻总数:<%= totalRecord %> 当前页数:<%=currentPage%> 每页显示<%=PageNumbers%>条 共<%=(totalRecord+PageNumbers)/PageNumbers%>页 <a href="index.jsp?page=1">首页</a> <% if(intPage>1 && intPage<((totalRecord+PageNumbers)/PageNumbers)) { out.print("<a href='index.jsp?page=" + (intPage-1) + "'>上一页 </a>"); out.print("<a href='index.jsp?page=" + (intPage+1) +"'>下一页 </a>"); out.print("<a href='index.jsp?page=" + ((totalRecord+PageNumbers)/PageNumbers) + "'>最后一页</a>"); } if(intPage ==((totalRecord+PageNumbers)/PageNumbers)) out.print("<a href='index.jsp?page=" + (intPage-1) + "'>上一页 </a>"); if(intPage == 1) { out.print("<a href='index.jsp?page=" + (intPage+1) +"'>下一页 </a>"); out.print("<a href='index.jsp?page=" + ((totalRecord+PageNumbers)/PageNumbers) + "'>最后一页</a>"); } %> </div> <% counters.close(); %> <div align="center"><a href="manager.jsp" >进入管理</a> <a href="manager.jsp">发布文章</a> <a href="admin.jsp">登录</a><br> <%@ include file="inc/bottom.jsp" %></div> </body> </html> 一个新闻发布系统的主页面,Mysql.java是相关的 mysql jdbc操作. 运行出错: type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause java.lang.NullPointerException org.apache.jsp.index_jsp._jspService(index_jsp.java:72) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs. 关于 异常 。。。。 谢谢指教 |
话题树型展开 |
人气 | 标题 | 作者 | 字数 | 发贴时间 |
2020 | 各位大虾帮帮忙 | J2EE1982 | 4489 | 2005-08-18 17:57 |
1569 | Re:各位大虾帮帮忙 | chengbd | 125 | 2005-08-19 02:17 |
1633 | Re:各位大虾帮帮忙 | chengbd | 78 | 2005-08-19 02:24 |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |