EmpPreDelAction.java
上传用户:jishiqi_cj
上传日期:2022-08-08
资源大小:24765k
文件大小:2k
源码类别:

Java编程

开发平台:

Java

  1. package StudyNote;
  2. import javax.servlet.http.HttpServletRequest;
  3. import javax.servlet.http.HttpServletResponse;
  4. import org.apache.struts.action.Action;
  5. import org.apache.struts.action.ActionForm;
  6. import org.apache.struts.action.ActionForward;
  7. import org.apache.struts.action.ActionMapping;
  8. import javax.servlet.ServletContext;
  9. import javax.sql.DataSource;
  10. import java.sql.Connection;
  11. import java.sql.Statement;
  12. import java.sql.ResultSet;
  13. import java.sql.SQLException;
  14. import java.util.*;
  15. import javax.servlet.http.*;
  16. import org.apache.struts.action.ActionMessage;
  17. import org.apache.struts.action.ActionMessages;
  18. public final class EmpPreDelAction extends Action{  
  19. public ActionForward execute(
  20. ActionMapping mapping,
  21. ActionForm form,
  22. HttpServletRequest request,  
  23. HttpServletResponse response) throws Exception {
  24.         HttpSession session = request.getSession();
  25. Vector depList = new Vector();
  26.     ServletContext context = servlet.getServletContext();
  27. DataSource dataSource = 
  28. (DataSource)context.getAttribute(Constants.DATASOURCE_KEY);
  29.         DB db = new DB(dataSource);
  30.         
  31. String PageForward;
  32. ActionMessages errors = new ActionMessages();
  33.     String username=(String)session.getAttribute(Constants.LOGIN_USERNAME_KEY);
  34. if (InterUser.GetUserGrade(db,username)!=1){
  35.             errors.add(ActionMessages.GLOBAL_MESSAGE,
  36.                            new ActionMessage("errors.accessDeny"));
  37. if (!errors.isEmpty()) {
  38. saveErrors(request, errors);
  39.   PageForward="toWrong";  
  40. }
  41. else{
  42. session.setAttribute(Constants.EMP_LIST_KEY,Emp.Search(db,0,""));
  43.   PageForward="toEmpDel";  
  44. }
  45.    
  46. db.close();
  47.     return (mapping.findForward(PageForward));
  48.   }
  49. }