Advertisement
Guest User

loginAction

a guest
Apr 8th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <%@page import="uts.wsd.*" import="java.util.*" contentType="text/html" pageEncoding="UTF-8"%>
  2.  
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>Login Action</title>
  8. </head>
  9. <body>
  10. <% String filePath = application.getRealPath("WEB-INF/users.xml");%>
  11. <jsp:useBean id="diaryApp" class="uts.wsd.DiaryApplication" scope="application">
  12. <jsp:setProperty name="diaryApp" property="filePath" value="<%=filePath%>"/>
  13. </jsp:useBean>
  14. <%
  15. String password = request.getParameter("password");
  16. String email = request.getParameter("email");
  17. Users users = diaryApp.getUsers();
  18. User user = users.login(email, password);
  19. %>
  20. <%
  21. if (user != null) {
  22. session.setAttribute("user", user);
  23. %>
  24. <fieldset>
  25. <legend>loginAction.jsp</legend>
  26. <p>Login successful. Click <a href="index.jsp"> here</a> to return to the main page.</p>
  27. </fieldset>
  28. <% } else {%>
  29. <fieldset>
  30. <legend>loginAction.jsp</legend>
  31. <p>Password incorrect. Click <a href="login.jsp"> here</a> to try again.</p>
  32. <%}%>
  33. </fieldset>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement