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. | |
cb44f6c1 | 29 | //FIXME: Enforce unicode request and response |
05e819e4 JB |
30 | login = request.getParameter("login"); |
31 | password = request.getParameter("password"); | |
32 | PrintWriter out = response.getWriter(); | |
33 | out.println("<html>"); | |
34 | out.println("<body>"); | |
35 | out.println("Login: " + login); | |
36 | out.println("<br>"); | |
37 | out.println("Password: " + password); | |
38 | out.println("</body>"); | |
39 | out.println("</html>"); | |
40 | } | |
41 | ||
42 | public void doPost(HttpServletRequest request, HttpServletResponse response) | |
43 | throws ServletException, IOException { | |
44 | ||
45 | // Set response content type | |
46 | response.setContentType("text/html"); | |
47 | ||
48 | // Actual logic goes here. | |
49 | login = request.getParameter("login"); | |
50 | password = request.getParameter("password"); | |
51 | PrintWriter out = response.getWriter(); | |
52 | out.println("<html>"); | |
53 | out.println("<body>"); | |
54 | out.println("Login: " + login); | |
55 | out.println("<br>"); | |
56 | out.println("Password: " + password); | |
57 | out.println("</body>"); | |
58 | out.println("</html>"); | |
59 | } | |
60 | ||
61 | public void destroy() { | |
62 | ||
63 | } | |
64 | } |