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