|
40 | 40 | package org.javaee7.servlet.metadata.complete;
|
41 | 41 |
|
42 | 42 | import java.io.IOException;
|
43 |
| -import java.io.PrintWriter; |
44 | 43 | import javax.servlet.ServletException;
|
45 | 44 | import javax.servlet.annotation.WebServlet;
|
46 | 45 | import javax.servlet.http.HttpServlet;
|
|
52 | 51 | */
|
53 | 52 | @WebServlet(urlPatterns = "/RandomName")
|
54 | 53 | public class TestServlet extends HttpServlet {
|
55 |
| - |
56 |
| - /** |
57 |
| - * Processes requests for both HTTP <code>GET</code> and <code>POST</code> |
58 |
| - * methods. |
59 |
| - * |
60 |
| - * @param request servlet request |
61 |
| - * @param response servlet response |
62 |
| - * @throws ServletException if a servlet-specific error occurs |
63 |
| - * @throws IOException if an I/O error occurs |
64 |
| - */ |
65 |
| - protected void processRequest(HttpServletRequest request, HttpServletResponse response) |
66 |
| - throws ServletException, IOException { |
67 |
| - response.setContentType("text/html;charset=UTF-8"); |
68 |
| - PrintWriter out = response.getWriter(); |
69 |
| - out.println("<!DOCTYPE html>"); |
70 |
| - out.println("<html>"); |
71 |
| - out.println("<head>"); |
72 |
| - out.println("<title>Servlet url-pattern in web.xml</title>"); |
73 |
| - out.println("</head>"); |
74 |
| - out.println("<body>"); |
75 |
| - out.println("<h1>Servlet url-pattern in web.xml</h1>"); |
76 |
| - out.println("</body>"); |
77 |
| - out.println("</html>"); |
78 |
| - } |
79 |
| - |
80 |
| - // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> |
81 |
| - /** |
82 |
| - * Handles the HTTP <code>GET</code> method. |
83 |
| - * |
84 |
| - * @param request servlet request |
85 |
| - * @param response servlet response |
86 |
| - * @throws ServletException if a servlet-specific error occurs |
87 |
| - * @throws IOException if an I/O error occurs |
88 |
| - */ |
89 | 54 | @Override
|
90 | 55 | protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
91 | 56 | throws ServletException, IOException {
|
92 |
| - processRequest(request, response); |
| 57 | + response.getWriter().print("my GET"); |
93 | 58 | }
|
94 | 59 |
|
95 |
| - /** |
96 |
| - * Handles the HTTP <code>POST</code> method. |
97 |
| - * |
98 |
| - * @param request servlet request |
99 |
| - * @param response servlet response |
100 |
| - * @throws ServletException if a servlet-specific error occurs |
101 |
| - * @throws IOException if an I/O error occurs |
102 |
| - */ |
103 | 60 | @Override
|
104 | 61 | protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
105 | 62 | throws ServletException, IOException {
|
106 |
| - processRequest(request, response); |
| 63 | + response.getWriter().print("my POST"); |
107 | 64 | }
|
108 |
| - |
109 |
| - /** |
110 |
| - * Returns a short description of the servlet. |
111 |
| - * |
112 |
| - * @return a String containing servlet description |
113 |
| - */ |
114 |
| - @Override |
115 |
| - public String getServletInfo() { |
116 |
| - return "Short description"; |
117 |
| - }// </editor-fold> |
118 | 65 | }
|
0 commit comments