📄 clearbasketcontroller.java
字号:
package LL;
import LL.LibraryBasket;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class ClearBasketController extends HttpServlet{
public void doPost(HttpServletRequest request,HttpServletResponse response){
try {HttpSession mySession=request.getSession();
/**Load the myBasket bean from the HtttpSession.
*This returns a copy of the object in the session
*/
LibraryBasket myBasket=(LibraryBasket) mySession.getAttribute("myBasket");
/**
* process the requst from the jsp to clear the basket
*/
myBasket=new LibraryBasket();
/**
* Set the bean back into the session for later use. This
* method will associate the myBasket bean with the name "myBasket"
*/
mySession.setAttribute("myBasket",myBasket);
/**
* back to the main page
*/
RequestDispatcher rd;
rd=getServletContext().getRequestDispatcher("/viewbasket.jsp");
rd.forward(request, response);
}catch(Exception e){
System.out.println(e.toString());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -