Commit | Line | Data |
---|---|---|
05e819e4 JB |
1 | package form; |
2 | ||
3 | // Import required java libraries | |
4 | import java.io.*; | |
5 | import javax.servlet.*; | |
6 | import javax.servlet.http.*; | |
7 | import javax.servlet.annotation.WebServlet; | |
8 | ||
9 | @WebServlet(name="Login", urlPatterns={"/Login"}) | |
10 | // Extend HttpServlet class | |
11 | public class Login extends HttpServlet { | |
12 | ||
13 | private String login; | |
14 | private String password; | |
15 | ||
16 | public void init() throws ServletException { | |
17 | // Do required initialization | |
18 | login = new String(); | |
19 | password = new String(); | |
20 | } | |
21 | ||
22 | public void doGet(HttpServletRequest request, HttpServletResponse response) | |
23 | throws ServletException, IOException { | |
24 | ||
25 | // Set response content type | |
26 | response.setContentType("text/html"); | |
27 | ||
28 | // Actual logic goes here. | |
29 | login = request.getParameter("login"); | |
30 | password = request.getParameter("password"); | |
31 | PrintWriter out = response.getWriter(); | |
32 | out.println("<html>"); | |
33 | out.println("<body>"); | |
34 | out.println("Login: " + login); | |
35 | out.println("<br>"); | |
36 | out.println("Password: " + password); | |
37 | out.println("</body>"); | |
38 | out.println("</html>"); | |
39 | } | |
40 | ||
41 | public void doPost(HttpServletRequest request, HttpServletResponse response) | |
42 | throws ServletException, IOException { | |
43 | ||
44 | // Set response content type | |
45 | response.setContentType("text/html"); | |
46 | ||
47 | // Actual logic goes here. | |
48 | login = request.getParameter("login"); | |
49 | password = request.getParameter("password"); | |
50 | PrintWriter out = response.getWriter(); | |
51 | out.println("<html>"); | |
52 | out.println("<body>"); | |
53 | out.println("Login: " + login); | |
54 | out.println("<br>"); | |
55 | out.println("Password: " + password); | |
56 | out.println("</body>"); | |
57 | out.println("</html>"); | |
58 | } | |
59 | ||
60 | public void destroy() { | |
61 | ||
62 | } | |
63 | } |