📄 6091c4eba20a001c126d85d192d96ccb
字号:
import bean.*;
import java.util.*;
import java.io.*;
import java.net.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* Class <b>SearchController</b> contains
* the servlet controller functionality for processing
* user search requests.
*
*
* @author ProjectGroup
* @version 1.0.0
*/
public class PastOrderController extends Controller {
/**
* SearchController doPost method. This is can be called
* by <b>Controller</b> superclass' doGet() method.
* @param req HttpServletRequest servlet request object
* @param res HttpServletResponse servlet response object
* @throws ServletException
* @throws IOException
*/
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
HttpSession session=req.getSession();
Customer customer=(Customer)session.getAttribute("customer");
String cn=customer.getNum();
String sql="select * from orders where C_num='"+cn+"'";
OrderSet orderset=new OrderSet();
try {
ResultSet r = null;
// Get an instance of the singleton DBWrapper object.
DBWrapper db = DBWrapper.Instance();
// Run the query.
r = db.runQuery( sql );
// Fill the BookTitleSet with BookTitles.
while (r.next()) {
Order or=new Order(r.getString("O_num"),r.getString("C_num"),r.getString("O_mailAddress"),r.getString("O_shipingdate"),r.getString("O_datePlaced"),r.getString("O_shipMeathod"),r.getFloat("O_totalCost"),r.getString("credCar_num"));
orderset.addOrder(or);
}
} catch ( Exception e ) {
// Send this exception to the standard error page.
sendErrorRedirect(req, res, e);
}
/**
* Redirect to the search.jsp page to display the search results.
* The search results are stored in the HttpServletRequest's
* session.
*/
try {
session.setAttribute("orderset", orderset);
// Be sure to tell search.jsp that it should initially show books 0-9, i.e. the first ten books.
res.sendRedirect("/e-commerce/pastorders.jsp?start=0");System.out.println("1111111");
} catch( Exception e ){
sendErrorRedirect(req, res, e);
}
return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -