求助:JSP的一个异常
程序代码:
org.apache.jasper.JasperException: Exception in JSP: /mailBoxSave.jsp:33
30:
31: //mailbox.setReceiveID(1);
32:
33: boolean isAdd = mangeDB.addMailBox(mailbox);
34:
35: if(isAdd){
36: out.println("发送成功,且已经保存至草稿箱");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException
com.netshop.ManageDB.exeSqlUpdate(ManageDB.java:51)
com.netshop.ManageDB.addMailBox(ManageDB.java:68)
org.apache.jsp.mailBoxSave_jsp._jspService(mailBoxSave_jsp.java:93)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
30:
31: //mailbox.setReceiveID(1);
32:
33: boolean isAdd = mangeDB.addMailBox(mailbox);
34:
35: if(isAdd){
36: out.println("发送成功,且已经保存至草稿箱");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException
com.netshop.ManageDB.exeSqlUpdate(ManageDB.java:51)
com.netshop.ManageDB.addMailBox(ManageDB.java:68)
org.apache.jsp.mailBoxSave_jsp._jspService(mailBoxSave_jsp.java:93)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
代码如下:
程序代码:
<%@ page language="java" contentType="text/html; charset=gbk"
pageEncoding="gbk"%>
<%@ page import="java.sql.*,java.text.*"%>
<jsp:useBean scope="page" id = "mailbox" class = "com.netshop.MailBox"/>
<jsp:useBean scope="page" id = "mangeDB" class = "com.netshop.ManageDB"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>发送成功</title>
</head>
<body>
<%--传进用户姓名的参数--%>
<%
//实际是后面应该传入的参数,但是为了检测,我先让它固定为一个值
String userName = "yuxinabc001";
int authorID = 7;
request.setCharacterEncoding("gbk");
mailbox.setAuthorID(authorID);
mailbox.setSendName(userName);
//mailbox.setReceiveName(request.getParameter("receiveName"));
mailbox.setReceiveName("receiveName");
mailbox.setTag(1);
mailbox.setTitle("title");
mailbox.setContent("content");
//mailbox.setReceiveID(1);
boolean isAdd = mangeDB.addMailBox(mailbox);
if(isAdd){
out.println("发送成功,且已经保存至草稿箱");
}else{
out.println("失败");
}
%>
</body>
</html>
pageEncoding="gbk"%>
<%@ page import="java.sql.*,java.text.*"%>
<jsp:useBean scope="page" id = "mailbox" class = "com.netshop.MailBox"/>
<jsp:useBean scope="page" id = "mangeDB" class = "com.netshop.ManageDB"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>发送成功</title>
</head>
<body>
<%--传进用户姓名的参数--%>
<%
//实际是后面应该传入的参数,但是为了检测,我先让它固定为一个值
String userName = "yuxinabc001";
int authorID = 7;
request.setCharacterEncoding("gbk");
mailbox.setAuthorID(authorID);
mailbox.setSendName(userName);
//mailbox.setReceiveName(request.getParameter("receiveName"));
mailbox.setReceiveName("receiveName");
mailbox.setTag(1);
mailbox.setTitle("title");
mailbox.setContent("content");
//mailbox.setReceiveID(1);
boolean isAdd = mangeDB.addMailBox(mailbox);
if(isAdd){
out.println("发送成功,且已经保存至草稿箱");
}else{
out.println("失败");
}
%>
</body>
</html>
其中MailBox类就是一些get,set方法。而且我确定ManageDB类正确,因为另写main检验和数据库的那个类是正确的。
因为本人才接触JSP,所以不是太会,希望得到大家的帮助!我会在线等待,或发到我邮箱:yuxinabc001@126.com
谢谢大家了!
搜索更多相关主题的帖子:
JSP
----------------解决方案--------------------------------------------------------
应该是
boolean isAdd = mangeDB.addMailBox(mailbox);
这一句的问题,
仔细检查下addMailBox函数,可能有问题
----------------解决方案--------------------------------------------------------
com.netshop.ManageDB.exeSqlUpdate(ManageDB.java:51)
很可能更新数据库的时候出问题,数据不全什么的
----------------解决方案--------------------------------------------------------