📄 f04e6164810a001c140682e9af1aa5b1
字号:
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 sql="select * from orders where C_num='"+customer.getNum()+"'";
// The results of the search are to be stored in a BookTitleSet object.
OrderSet orders=new OrderSet();
// Execute the search and fill the BookTitleSet with the results.
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_dataPlaced"),
r.getString( "O_shipingMeathod" ), Double.parseDouble(r.getString( "O_totalCost" )),r.getString( "credCar_num" ));
orders.addOrder(or);
System.out.print(orders.getOrderCount());
}
} 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("orders", orders);
// 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");
} catch( Exception e ){
sendErrorRedirect(req, res, e);
}
return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -