Guest User

Untitled

a guest
Dec 2nd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. package les_forms;
  2.  
  3. import java.util.Enumeration;
  4.  
  5. import ironman.StudentData;
  6. import ironman.Util;
  7.  
  8. import javax.servlet.http.HttpServletRequest;
  9.  
  10. import org.apache.struts.action.ActionErrors;
  11. import org.apache.struts.action.ActionForm;
  12. import org.apache.struts.action.ActionMapping;
  13. import org.apache.struts.action.ActionMessage;
  14.  
  15. public class RegistrationForm extends ActionForm {
  16.  
  17. private static final long serialVersionUID = 1L;
  18.  
  19. private String username , password , cpassword, email;
  20.  
  21. public void setUsername(String username) {
  22. this.username = username;
  23. }
  24.  
  25. public String getUsername() {
  26. return username;
  27. }
  28.  
  29. public void setPassword(String password) {
  30. this.password = password;
  31. }
  32.  
  33. public String getPassword() {
  34. return password;
  35. }
  36.  
  37. public void setCpassword(String cpassword) {
  38. this.cpassword = cpassword;
  39. }
  40.  
  41. public String getCpassword() {
  42. return cpassword;
  43. }
  44.  
  45. public void setEmail(String email) {
  46. this.email = email;
  47. }
  48.  
  49. public String getEmail() {
  50. return email;
  51. }
  52.  
  53. /**
  54. * Reset all properties to their default values.
  55. *
  56. * @param mapping
  57. * The mapping used to select this instance
  58. * @param request
  59. * The servlet request we are processing
  60. */
  61. public void reset(ActionMapping mapping, HttpServletRequest request) {
  62. setUsername(null);
  63. setPassword(null);
  64. setCpassword(null);
  65. setEmail(null);
  66. }
  67.  
  68. /**
  69. * Validate the input data. If validation fails, then report the errors in
  70. * students.jsp, and specifically where <html:errors/> is located.
  71. *
  72. * @param mapping
  73. * The mapping used to select this instance
  74. * @param request
  75. * The servlet request we are processing
  76. */
  77. public ActionErrors validate(ActionMapping mapping,
  78. HttpServletRequest request) {
  79.  
  80. System.err.println("in REGISTRATION form");
  81.  
  82. ActionErrors errors = new ActionErrors();
  83.  
  84. // System.err.println("NAME: "+username+" "+password+" "+confirmPassword);
  85.  
  86. if ((username == null) || (username.length() < 1)){
  87. errors.add("firstMsgTag1", new ActionMessage("errors.required","Username"));
  88. System.err.println("leave form in error 1");
  89. return errors;
  90. }
  91.  
  92. if ((password == null) || (password.length() < 1)){
  93. errors.add("lastMsgTag1", new ActionMessage("errors.required","Password"));
  94. System.err.println("leave form in error 2");
  95. return errors;
  96. }
  97.  
  98. if ((cpassword == null) || (cpassword.length() < 1)){
  99. errors.add("lastMsgTag1", new ActionMessage("errors.required","Confirm Password"));
  100. System.err.println("leave form in error 3");
  101. return errors;
  102. }
  103.  
  104. if (!password.equals(cpassword)){
  105. errors.add("lastMsgTag1", new ActionMessage("errors.required","Passwords Do Not Match"));
  106. System.err.println("leave form in error 4");
  107. return errors;
  108. }
  109.  
  110. if ((email == null) || (email.length() < 1)){
  111. errors.add("lastMsgTag1", new ActionMessage("errors.required","Email"));
  112. System.err.println("leave form in error 5");
  113. return errors;
  114. }
  115.  
  116. System.err.println("leave REGISTRATION form with no errors");
  117.  
  118. return errors;
  119. }
  120.  
  121. }
Add Comment
Please, Sign In to add comment