?? cdmanageservlet.java
字號:
package mypack;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class CdManageServlet extends HttpServlet implements Servlet {
public CdManageServlet() {
super();
}
protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
String id =arg0.getParameter("updateid");
System.out.println(id);
String cdId=null;
String subject_name=null;
try{
Cdstore cdstore=new Cdstore();
CdDetails mycd = new CdDetails();
if (id!=null){
cdId = id;
mycd = cdstore.getCdDetails(id);
}
HttpSession session = arg0.getSession(true);
session.setAttribute("cdId",cdId);
session.setAttribute("title",mycd.getTitle());
session.setAttribute("name",mycd.getName());
session.setAttribute("price",mycd.getPrice());
session.setAttribute("year",mycd.getYear());
session.setAttribute("description",mycd.getDescription());
session.setAttribute("saleamount",mycd.getSaleAmount());
session.setAttribute("warehouse",mycd.getWarehouse());
session.setAttribute("saletype",mycd.getSaletype());
arg1.sendRedirect("cdedit.jsp");
}
catch(Exception e){
}
}
protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
String delete = arg0.getParameter("delete");
try{
if (delete!=null)
{
CdDetails mycd = new CdDetails();
Cdstore cdstore=new Cdstore();
String[] check=arg0.getParameterValues("check");
if(check !=null)
{
for (int i=0;i<check.length;i++)
{
cdstore.deleteCd(check[i]);
}
}
else
{
PrintWriter out = arg1.getWriter();
out.print("<script language='javascript'>");
out.print("alert('please choose the cdid you want to delete!');");
out.print("window.location.href='cdmanage.jsp';");
out.print("</script>");
return;
}
arg1.sendRedirect("cdmanage.jsp");
}
}
catch(Exception e){
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -