PrePubNoteAction.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 PrePubNoteAction 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.     ServletContext context = servlet.getServletContext();
  26. DataSource dataSource = 
  27. (DataSource)context.getAttribute(Constants.DATASOURCE_KEY);
  28.         DB db = new DB(dataSource);
  29.         
  30. String PageForward;
  31. ActionMessages errors = new ActionMessages();
  32.     String username=(String)session.getAttribute(Constants.LOGIN_USERNAME_KEY);
  33. if (username==null){
  34.             errors.add(ActionMessages.GLOBAL_MESSAGE,
  35.                            new ActionMessage("errors.accessDeny"));
  36. if (!errors.isEmpty()) {
  37. saveErrors(request, errors);
  38.   PageForward="toWrong";  
  39. }
  40. else{
  41. InterUser.GetEmpName(db,username);
  42. session.setAttribute(Constants.TALKER_NAME_KEY,InterUser.GetEmpName(db,username));
  43.   PageForward="toNoteAdd";
  44.   saveToken(request);  //避免重复提交
  45.     }
  46. db.close();
  47.     return (mapping.findForward(PageForward));
  48.   }
  49. }