Guest User

Untitled

a guest
Oct 9th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. package com.jdepths;
  2.  
  3. import java.io.IOException;
  4.  
  5. import javax.ejb.EJB;
  6. import javax.servlet.ServletException;
  7. import javax.servlet.annotation.WebServlet;
  8. import javax.servlet.http.HttpServlet;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11.  
  12. /**
  13. * This class processes the requests from the form
  14. * @author Hathy
  15. */
  16. @WebServlet("/HashIt")
  17. public class HashIt extends HttpServlet {
  18. private static final long serialVersionUID = 1L;
  19.  
  20. @EJB
  21. private Hash hash;
  22.  
  23. public HashIt() {
  24. super();
  25. }
  26.  
  27. protected void doGet(HttpServletRequest request,
  28. HttpServletResponse response)
  29. throws ServletException, IOException {
  30. // Let us always use the doPost
  31. doPost(request,response);
  32. }
  33.  
  34. protected void doPost(HttpServletRequest request,
  35. HttpServletResponse response)
  36. throws ServletException, IOException {
  37.  
  38. String username=request.getParameter("username");
  39. String password=request.getParameter("password");
  40.  
  41. if(username==null || username.length()==0)
  42. username="EMPTY";
  43. if(password==null || password.length()==0)
  44. password="EMPTY";
  45.  
  46. response.getWriter().println(
  47. "The SHA-1 of the form data is "+
  48. hash.digest(username+password)
  49. );
  50. }
  51. }
Add Comment
Please, Sign In to add comment