📄 lastconfirm.jsp
字号:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="javax.mail.*" %>
<%@ page import="javax.mail.internet.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.iss.dataBase.SQLParser" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.iss.bean.*" %>
<%@ page import="com.iss.dao.*" %>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>
<!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=UTF-8">
<title>Last information</title>
</head>
<body>
<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
<!-- Let's welcome the user ${param.name} -->
Hello ${param.name}!
</c:if>
--%>
<%
Statement stmt=SQLParser.getInstance().getStmt();
ShopCart shopcart=(ShopCart)session.getAttribute("shopcart");
String sql="select * from ordertable order by ordernumber desc";
ResultSet rs=stmt.executeQuery(sql);
int temp;
if(rs.next())
temp=rs.getInt("ordernumber");
else temp=0;
List<BookBean> b=shopcart.getBooks();
if(b!=null)
{
try
{
sql="insert into ordertable values ("+(temp+1)+",now(),'"+ (String)request.getParameter("method")+"' ,'"+(String)request.getParameter("address")+"','"+(String)request.getParameter("customerName")+"')";
stmt.executeUpdate(sql);
sql="select * from orderitem order by id desc";
rs=stmt.executeQuery(sql);
int temp2;
if(rs.next())
temp2=rs.getInt("id");
else temp2=0;
for(int i=0;i<shopcart.getBookCount();i++) {
sql="insert into orderItem values ("+(temp+1)+",'"+b.get(i).getBook().getIsbn()+"',"+b.get(i).getCount()+","+(temp2+1)+")";
stmt.executeUpdate(sql);
sql ="update stock set quantity = quantity - " +b.get(i).getBook().getCount()+"where ISBN ='" +b.get(i).getBook().getIsbn()+"'";
stmt.executeUpdate(sql);
}
out.print("<html><head><title></title><body>订单已经上传,你可以返回<a href='index.jsp'>主页继续购物</a></body></html>");
}
catch(Exception e)
{
out.print("<html><head><title></title><body>订单已经上传,你可以返回<a href='index.jsp'>主页继续购物</a></body></html>");
}
}
else
out.print("<html><head><title></title><body>你还没有购物</body></html>");
%>
<%--<%
Statement stmt=SQLParser.getInstance().getStmt();
String customerName=(String)session.getAttribute("customerName");
String sql="select * from customer where customerName = "+customerName;
ResultSet rs = stmt.executeQuery(sql);//这里好像这个方法没有在提示之内
rs.next();
String to_mail=rs.getString("Email");
String to_title="欢迎购买图书";
String to_content="你的图书已经成功订购,我们会在预定时间内到达";
Properties props=new Properties();
props.put("mail.smtp.host","smtp.yahoo.com.cn");
props.put("mail.smtp.auth","true");
Session s=Session.getInstance(props);
s.setDebug(true);
MimeMessage message=new MimeMessage(s);
InternetAddress from=new InternetAddress("shenshuijing06@yahoo.com.cn");
message.setFrom(from);
InternetAddress to=new InternetAddress(to_mail);
message.setRecipient(message.RecipientType.To,to);
message.setSubject(to_title);
message.setText(to_content);
message.setSentDate(new Date());
message.saveChanges();
Transport transport=s.getTransport("smpt");
transport.connect("smtp.126.com","shenshuijing06","1231312");
transport.sendMessage(message,message.getAllRecipients());
transport.close();
out.print("你的订单已经被接受");
%>
--%></body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -