Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.72 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Login Page</title>
  5. <meta charset="UTF-8"/>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  7. <style>
  8. header {
  9. background-color:lightsteelblue;
  10. color:white;
  11. text-align:center;
  12. padding:5px;
  13. }
  14. nav {
  15. line-height:30px;
  16. height:300px;
  17. width:100px;
  18. float:left;
  19. padding:5px;
  20. }
  21. section {
  22. width:600px;
  23. float:right;
  24. padding:220px;
  25. }
  26. footer {
  27. background-color:black;
  28. color:white;
  29. clear:both;
  30. float:bottom;
  31. text-align:center;
  32. padding:5px;
  33. }
  34. </style>
  35. </head>
  36. <body style="background-color: lightsteelblue">
  37. <header>
  38. <canvas id="myCanvas" width="500" height="100" style="border:2px solid black; background-color:burlywood ">
  39. Your browser does not support the HTML5 canvas tag.</canvas>
  40.  
  41. <script>
  42. var c = document.getElementById("myCanvas");
  43. var ctx = c.getContext("2d");
  44. ctx.font = "45px Arial";
  45. ctx.strokeText("File Tracking System", 50, 50);
  46.  
  47. </script>
  48. </header>
  49. <a href="forgotpass.jsp">Forgot Your Password</a>
  50. <section>
  51. <form action="LoginServlet" method="post">
  52. Username: <input type="text" name="user"/>
  53. <br />
  54. Password: <input type="password" name="pwd"/>
  55. <br />
  56. <input type="submit" value="Login"/>
  57.  
  58. </form>
  59. <img src="css/NSIC-logo1.png" width="537" height="267" alt="NSIC-logo1"/>
  60. </section>
  61. <footer>Copyright 2016 NSIC. All right reserved.</footer>
  62. </body>
  63. </html>
  64.  
  65. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  66. <!DOCTYPE html>
  67. <html>
  68. <head>
  69. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  70. <title>Forgot Password Page</title>
  71. <style>
  72. header {
  73. background-color:teal;
  74. color:white;
  75. text-align:center;
  76. padding:5px;
  77. }
  78. nav {
  79. line-height:30px;
  80. height:300px;
  81. width:120px;
  82. float:left;
  83. padding:5px;
  84. }
  85. section {
  86. width:800px;
  87. float:right;
  88. padding:130px;
  89. }
  90. footer {
  91. background-color:black;
  92. float:bottom;
  93. color:white;
  94. clear:both;
  95. text-align:center;
  96. padding:5px;
  97. }
  98. </style>
  99. </head>
  100. <body style="background-color:lightsteelblue;">
  101. <header><h3>File Tracking System!!</h3>
  102. <br>
  103. </header>
  104. <nav>
  105. <form action="forgotServlet" method="POST" >
  106. User Name:<input type="text" name="name" value="" size="20" />
  107. Email:<input type="text" name="email" value="" size="20" />
  108. New Password:<input type="text" name="pass1" value="" size="20" />
  109. Repeat Password:<input type="text" name="pass2" value="" size="20" />
  110. <input type="submit" value="submit" name="submit" />
  111. </form>
  112. </nav>
  113. <section><img src="css/NSIC-logo1.png" width="537" height="267" alt="NSIC-logo1"/></section>
  114. <footer>
  115. Copyright 2016 NSIC. All right reserved.
  116. </footer>
  117. </body></html>
  118.  
  119. <!DOCTYPE html>
  120. <html>
  121. <head>
  122. <title>Forgot Password Page</title>
  123. <meta charset="UTF-8"/>
  124. <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  125. <style>
  126. header {
  127. background-color:teal;
  128. color:white;
  129. text-align:center;
  130. padding:5px;
  131. }
  132. nav {
  133. line-height:30px;
  134. height:300px;
  135. width:120px;
  136. float:left;
  137. padding:5px;
  138. }
  139. section {
  140. width:800px;
  141. float:right;
  142. padding:130px;
  143. }
  144. footer {
  145. background-color:black;
  146. float:bottom;
  147. color:white;
  148. clear:both;
  149. text-align:center;
  150. padding:5px;
  151. }
  152. </style>
  153. </head>
  154. <body style="background-color:lightsteelblue;">
  155. <header><h3>File Tracking System!!</h3>
  156. <br>
  157. </header>
  158. <nav>
  159. <form action="forgotServlet" method="POST" >
  160. User Name:<input type="text" name="name" value="" size="20" />
  161. Email:<input type="text" name="email" value="" size="20" />
  162. New Password:<input type="text" name="pass1" value="" size="20" />
  163. Repeat Password:<input type="text" name="pass2" value="" size="20" />
  164. <input type="submit" value="submit" name="submit" />
  165. </form>
  166. </nav>
  167. <section><img src="css/NSIC-logo1.png" width="537" height="267" alt="NSIC-logo1"/></section>
  168. <footer>
  169. Copyright 2016 NSIC. All right reserved.
  170. </footer>
  171. </body></html>
  172.  
  173. package bean;
  174.  
  175. import java.io.IOException;
  176. import javax.servlet.Filter;
  177. import javax.servlet.FilterChain;
  178. import javax.servlet.FilterConfig;
  179. import javax.servlet.ServletContext;
  180. import javax.servlet.ServletException;
  181. import javax.servlet.ServletRequest;
  182. import javax.servlet.ServletResponse;
  183. import javax.servlet.http.HttpServletRequest;
  184. import javax.servlet.http.HttpServletResponse;
  185. import javax.servlet.http.HttpSession;
  186.  
  187. public class AuthenticationFilter implements Filter {
  188.  
  189. private ServletContext context;
  190.  
  191. @Override
  192. public void init(FilterConfig fConfig) throws ServletException {
  193. this.context = fConfig.getServletContext();
  194. this.context.log("AuthenticationFilter initialized");
  195. }
  196.  
  197. @Override
  198. public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  199.  
  200. HttpServletRequest req = (HttpServletRequest) request;
  201. HttpServletResponse res = (HttpServletResponse) response;
  202.  
  203. res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
  204. res.setHeader("Pragma", "no-cache"); // HTTP 1.0.
  205. res.setDateHeader("Expires", 0); // Proxies.
  206.  
  207. String uri = req.getRequestURI();
  208. this.context.log("Requested Resource::" + uri);
  209.  
  210. HttpSession session = req.getSession(false);
  211.  
  212. if (session == null && !(uri.endsWith("html") || uri.endsWith("LoginServlet") || uri.endsWith("forgotpass.jsp") || uri.endsWith("doesnotexist.jsp") || uri.endsWith("pass.jsp"))) {
  213. this.context.log("Unauthorized access request");
  214. res.sendRedirect("index.html");
  215. } else {
  216. // pass the request along the filter chain
  217. chain.doFilter(request, response);
  218. }
  219.  
  220. }
  221.  
  222. @Override
  223. public void destroy() {
  224. //close any resources here
  225. }
  226.  
  227. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement