mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 10:58:42 +00:00
refactoring: Sonar issue fix for duplicate string (#2175)
This commit is contained in:
@@ -38,6 +38,7 @@ import java.io.PrintWriter;
|
||||
*/
|
||||
|
||||
public final class AppServlet extends HttpServlet {
|
||||
private static final String CONTENT_TYPE = "text/html";
|
||||
private String msgPartOne = "<h1>This Server Doesn't Support";
|
||||
private String msgPartTwo = "Requests</h1>\n"
|
||||
+ "<h2>Use a GET request with boolean values for the following parameters<h2>\n"
|
||||
@@ -61,7 +62,7 @@ public final class AppServlet extends HttpServlet {
|
||||
@Override
|
||||
public void doPost(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException {
|
||||
resp.setContentType("text/html");
|
||||
resp.setContentType(CONTENT_TYPE);
|
||||
try (PrintWriter out = resp.getWriter()) {
|
||||
out.println(msgPartOne + " Post " + msgPartTwo);
|
||||
}
|
||||
@@ -71,7 +72,7 @@ public final class AppServlet extends HttpServlet {
|
||||
@Override
|
||||
public void doDelete(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException {
|
||||
resp.setContentType("text/html");
|
||||
resp.setContentType(CONTENT_TYPE);
|
||||
try (PrintWriter out = resp.getWriter()) {
|
||||
out.println(msgPartOne + " Delete " + msgPartTwo);
|
||||
}
|
||||
@@ -80,7 +81,7 @@ public final class AppServlet extends HttpServlet {
|
||||
@Override
|
||||
public void doPut(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException {
|
||||
resp.setContentType("text/html");
|
||||
resp.setContentType(CONTENT_TYPE);
|
||||
try (PrintWriter out = resp.getWriter()) {
|
||||
out.println(msgPartOne + " Put " + msgPartTwo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user