|
This code, the error when I execute it is as follows;
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:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile (JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service (JspServlet.java:248)
javax.servlet.http.HttpServlet.service (HttpServlet.java:856)
root cause
java.lang.NullPointerException
bean.jdbcBean.closeDB (jdbcBean.java:41)
org.apache.jsp.checkout_jsp._jspService (checkout_jsp.java:172)
org.apache.jasper.runtime.HttpJspBase.service (HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service (HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service (JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile (JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service (JspServlet.java:248)
javax.servlet.http.HttpServlet.service (HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
Source:
<% @ page contentType = "text / html; charset = gb2312" language = "java" import = "java.sql. *" errorPage = ""%>
<! 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 = gb2312">
<title> Online Disc Store: Discs Endlessly </ title>
</ head>
<body>
<% @ include file = "header.jsp"%>
<table width = "800" height = "400" border = "1" align = "center">
<tr>
<td> <%
Vector buylist = (Vector) session.getValue ("shopcar");
if (buylist == null | buylist.size () <1)
{
%>
<jsp: forward page = "mydisk.jsp"> </ jsp: forward>
<%}
String userid = (String) session.getValue ("uid");
float pricenum = 0;
for (int i = 0; i <buylist.size (); i ++)
{
Disk disk = (Disk) buylist.elementAt (i);
pricenum = pricenum + disk.getBuynum () * disk.getPrice ();
}
Ransom
jdbcBean diskBean1 = new jdbcBean ();
String sql1 = "INSERT INTO myorder (user_id, price_num, order_time) VALUES ('" + userid + "'," + pricenum + ", '" + current_time + "')";
int m = diskBean1.executeUpdate (sql1);
diskBean1.closeDB ();
jdbcBean diskBean2 = new jdbcBean ();
String sql2 = "SELECT order_id FROM myorder WHERE order_id = '" + userid + "' AND order_time = '" + current_time + "'";
ResultSet rs = diskBean2.executeQuery (sql2);
rs.next ();
String orderid = rs.getString ("order_id");
diskBean2.closeDB ();
Ransom
for (int j = 0; j <buylist.size (); j ++)
{
Disk disk = (Disk) buylist.elementAt (j);
jdbcBean diskBean3 = new jdbcBean ();
String sql3 = "INSERT INTO orderitem (order_id, sno, disk_num) VALUES ('" + orderid + "', '" + disk.getSno () + "', '" + disk.getBuynum () + "')";
int mm = diskBean3.executeUpdate (sql3);
diskBean3.closeDB ();
}
%> </ td>
</ tr>
</ table>
<% @ include file = "footer.jsp"%>
</ body>
</ html>
I have included the required packages in header.jsp <% @ page import = "java.io. *"%>
<% @ page import = "java.util. *"%>
<% @ page import = "java.sql. *"%>
<% @ page import = "java.text. *"%>
<% @ page import = "bean. *"%>
The above code is wrong, but it can still insert data into the data table myorder, I look forward to your help !! |
|