java.lang.NullPointerException的问题,不知道是不是BEAN有问题还。。。
JSP页中代码:<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.lang.*"%>
<jsp:useBean id="connDB" scope="page" class="beans.connDB"/>
<!--<jsp:include page="safe.jsp"/>-->
<%
String id=request.getParameter("id");
String name=request.getParameter("name");
String type=request.getParameter("type");
String date=request.getParameter("date");
String photo=request.getParameter("file");
String price=request.getParameter("price");
String commend=request.getParameter("commend");
String isnew=request.getParameter("isnew");
String introduce=request.getParameter("introduce");
if(introduce.equals("")) introduce="暂无简介!";
ResultSet rs=connDB.executeQuery("select * from jz_product where jz_id='"+id+"'");
if(rs.next())
{
out.print("<script language='javascript'>alert('该编号信息已经存在!');history.back(-1);</script>");
}
else{
introduce=connDB.toStr(introduce);
String sql="insert into jz_product(jz_id,jz_name,jz_type,jz_date,jz_photo,jz_price,jz_commend,jz_isnew,jz_introduce) values('"+id+"','"+name+"','"+type+"','"+date+"','"+photo+"','"+price+"','"+commend+"','"+isnew+"','"+introduce+"')";
int flag=0;
flag=connDB.executeUpdate(sql);
if(flag!=0)
{
out.println("<script language='javascript'>alert('添加成功!');window.location.href='jz_add.jsp';</script>");
}
else
{
out.println("<script language='javascript'>alert('对不起,添加失败!');history.back(-1);</script>");
}
}
%>
ResultSet rs=connDB.executeQuery("select * from jz_product where jz_id='"+id+"'");
//这句话的操作数据库好像根本就没有执行,但是如果我把 上面的connDB.executeQuery改为connDB.executeQuery1也会报错说没有executeQuery1这样的方法.
我在bean中也写了测试语句,测试都是对的,在这里却不行
报错:
java.lang.NullPointerException
org.apache.jsp.system.jz_005fadd_005fact_jsp._jspService(jz_005fadd_005fact_jsp.java:68)
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)