commit | author | age
|
b12c95
|
1 |
/* |
U |
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package de.uhilger.filecms.web; |
|
7 |
|
|
8 |
import java.io.IOException; |
|
9 |
import java.io.PrintWriter; |
|
10 |
import javax.servlet.ServletException; |
|
11 |
import javax.servlet.http.HttpServlet; |
|
12 |
import javax.servlet.http.HttpServletRequest; |
|
13 |
import javax.servlet.http.HttpServletResponse; |
|
14 |
|
|
15 |
/** |
|
16 |
* |
|
17 |
* @author ulrich |
|
18 |
*/ |
|
19 |
public class TestServlet extends HttpServlet { |
|
20 |
|
|
21 |
/** |
|
22 |
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> |
|
23 |
* methods. |
|
24 |
* |
|
25 |
* @param request servlet request |
|
26 |
* @param response servlet response |
|
27 |
* @throws ServletException if a servlet-specific error occurs |
|
28 |
* @throws IOException if an I/O error occurs |
|
29 |
*/ |
|
30 |
protected void processRequest(HttpServletRequest request, HttpServletResponse response) |
|
31 |
throws ServletException, IOException { |
|
32 |
response.setContentType("text/html;charset=UTF-8"); |
|
33 |
try (PrintWriter out = response.getWriter()) { |
|
34 |
/* TODO output your page here. You may use following sample code. */ |
|
35 |
out.println("<!DOCTYPE html>"); |
|
36 |
out.println("<html>"); |
|
37 |
out.println("<head>"); |
|
38 |
out.println("<title>Servlet TestServlet</title>"); |
|
39 |
out.println("</head>"); |
|
40 |
out.println("<body>"); |
|
41 |
out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>"); |
|
42 |
out.println("</body>"); |
|
43 |
out.println("</html>"); |
|
44 |
} |
|
45 |
} |
|
46 |
|
|
47 |
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> |
|
48 |
/** |
|
49 |
* Handles the HTTP <code>GET</code> method. |
|
50 |
* |
|
51 |
* @param request servlet request |
|
52 |
* @param response servlet response |
|
53 |
* @throws ServletException if a servlet-specific error occurs |
|
54 |
* @throws IOException if an I/O error occurs |
|
55 |
*/ |
|
56 |
@Override |
|
57 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) |
|
58 |
throws ServletException, IOException { |
|
59 |
processRequest(request, response); |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* Handles the HTTP <code>POST</code> method. |
|
64 |
* |
|
65 |
* @param request servlet request |
|
66 |
* @param response servlet response |
|
67 |
* @throws ServletException if a servlet-specific error occurs |
|
68 |
* @throws IOException if an I/O error occurs |
|
69 |
*/ |
|
70 |
@Override |
|
71 |
protected void doPost(HttpServletRequest request, HttpServletResponse response) |
|
72 |
throws ServletException, IOException { |
|
73 |
processRequest(request, response); |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Returns a short description of the servlet. |
|
78 |
* |
|
79 |
* @return a String containing servlet description |
|
80 |
*/ |
|
81 |
@Override |
|
82 |
public String getServletInfo() { |
|
83 |
return "Short description"; |
|
84 |
}// </editor-fold> |
|
85 |
|
|
86 |
} |