Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Servlet/JSP/JSF/JavaFX Script  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to topicflat modethreaded modego to previous topicgo to next topicgo to back
作者 菜鸟问题,希望大虾们帮助
J2EE1982





发贴: 7
于 2005-08-16 07:42 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
jsp:源程序

<%@ page language = "java" contentType = "text/html;charset=ISO-8859-1" %>
<%@ page import = "java.sql.*" %>
<jsp:useBean id="mysql" scope="page" class="com.Mysql" />
<%
ResultSet rs = mysql.executeQuery("select * from stsnews");
while(rs.next()) {
out.println(rs.getString("title"));
}
%>

错误: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:59)
  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)




菜鸟请教,基本程序调试不通,急急急急急急!!!
作者 Re:菜鸟问题,希望大虾们帮助 [Re:J2EE1982]
chengbd



版主


发贴: 687
于 2005-08-17 01:12 user profilesend a private message to usersend email to chengbdreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
java.lang.NullPointerException
这是运行时错误了,没看到你的DB连接代码,应该是rs是个null值,却执行rs.next(),就出错了。
应该
ResultSet rs = mysql.executeQuery("select * from stsnews");
if(rs==null){
}
else
{
while(rs.next()) {
out.println(rs.getString("title"));
}
}



知难而进

搞笑QQ图片

reply to topicflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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