?? action.java
字號:
package com.ata.shoping.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.projiect.shopping.sql.UserDAO;
import com.projiect.shopping.sql.UserInfo;
public class Action extends HttpServlet {
/**
* Constructor of the object.
*/
public Action() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
// response.setCharacterEncoding("gb2312");
response.setContentType("text/html; charset=GBK");
String action=request.getParameter("action");
String id=request.getParameter("u_id");
out.print(id);
HttpSession session = null;
String money=null;
String vouchermoney=null;
try{
money=(String) session.getAttribute("session1");
vouchermoney=(String) session.getAttribute("session2");
}catch(Exception ee){}
out.print(money);
// String vouchermoney= request.getParameter("vouchermoney");
out.print(vouchermoney);
if(action.equals("delete"))
{
String sql="delete from userinfo where u_id="+id;
try
{
UserDAO.delete(sql);
response.sendRedirect("UserList1.jsp");
}catch(Exception e){}
}
// out.print("<TABLE cellSpacing=0 cellPadding=0 width=\"900\" border=1 height=\"45\" bgcolor=\"#00ff00\">");
// out.print("<TBODY><TR><TD background=Net008/hdr_nv_bg.gif height=30><A href=\"str\">會員列表</A>");
// out.print("</TD></TR></TBODY></TABLE><table width=\"\" border=\"1\" bgcolor=\"#c0c0c0\" height=\"208\" align=\"left\">");
// out.print("<tbody><tr><td >用戶ID</td><td >用戶名</td><td >密碼</td><td >email</td><td >電話號碼</td><td >帳戶余額</td><td >地址</td><td >注冊時間</td>");
// out.print("<td ><a href=\"/MyShopping/servlet/Action\" title=aaa>操作</a></td></tr>");
// UserDAO alluser1 = new UserDAO();
// String sql1 = "select * from userinfo";
// try
// {
// ArrayList<UserInfo> userlist1=alluser1.select(sql1);
// if(userlist1.size()>0)
// {
//
// for (int i = 0; i <=userlist1.size()-1; i++)
// {
//
// UserInfo user= new UserInfo();
//
// try{user= (UserInfo)userlist1.get(i);}catch(Exception ex){}
//
// String userActionStr = "<a href="+"\"/MyShopping/servlet/Action?action=delete&u_id="+ user.getU_id() + "\">刪除</a>";
// out.print("<tr>");
//
//
// out.print("<td>" + user.getU_id()+ "</td>");
// out.print("<td>" + user.getUserName() + "</td>");
// out.print("<td>" + user.getPassword() + "</td>");
// out.print("<td>" + user.getEmail() + "</td>");
// out.print("<td>" + user.getTelephone() + "</td>");
// out.print("<td>" + user.getMoney() + "</td>");
// out.print("<td>" + user.getAddr() + "</td>");
// out.print("<td>" + user.getCreatedate() + "</td>");
// out.print("<td>" + userActionStr+ "</td>");
// out.print("</tr>");
//
// }
// }}
// catch(Exception e){}
// }
// else
// if(action.equals("voucher"))
// {
// out.print(action.equals("voucher"));
//
// try
// {
// double setmoney=Double.parseDouble(money)+Double.parseDouble(vouchermoney);
// String sql="update userinfo set money="+setmoney+" where u_id="+id;
// out.print(sql);
// UserDAO.update(sql);
// out.print("充值成功");
// }catch(Exception ex){}
// }
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -