minor formatting cleanup
This commit is contained in:
parent
33f7b1a3b9
commit
a4c02d6275
|
@ -9,23 +9,13 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
public class ExampleOne extends HttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setContentType("text/html");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.println(
|
||||
"<!DOCTYPE html><html>" +
|
||||
"<head>" +
|
||||
"<meta charset=\"UTF-8\" />" +
|
||||
"<title>HTML Rendered by Servlet</title>" +
|
||||
"</head>" +
|
||||
"<body>" +
|
||||
"<h1>HTML Rendered by Servlet</h1></br>" +
|
||||
"<p>This page was rendered by the ExampleOne Servlet!</p>" +
|
||||
"</body>" +
|
||||
"</html>"
|
||||
);
|
||||
}
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setContentType("text/html");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.println("<!DOCTYPE html><html>" + "<head>" + "<meta charset=\"UTF-8\" />" + "<title>HTML Rendered by Servlet</title>" + "</head>" + "<body>" + "<h1>HTML Rendered by Servlet</h1></br>" + "<p>This page was rendered by the ExampleOne Servlet!</p>"
|
||||
+ "</body>" + "</html>");
|
||||
}
|
||||
}
|
|
@ -7,18 +7,14 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@WebServlet(
|
||||
name = "ExampleThree",
|
||||
description = "JSP Servlet With Annotations",
|
||||
urlPatterns = {"/ExampleThree"}
|
||||
)
|
||||
@WebServlet(name = "ExampleThree", description = "JSP Servlet With Annotations", urlPatterns = { "/ExampleThree" })
|
||||
public class ExampleThree extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
String message = request.getParameter("message");
|
||||
request.setAttribute("text", message);
|
||||
request.getRequestDispatcher("/jsp/ExampleThree.jsp").forward(request, response);
|
||||
}
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
String message = request.getParameter("message");
|
||||
request.setAttribute("text", message);
|
||||
request.getRequestDispatcher("/jsp/ExampleThree.jsp").forward(request, response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,19 +34,18 @@ public class ErrorController {
|
|||
errorMsg = "Http Error Code : 404. Resource not found";
|
||||
break;
|
||||
}
|
||||
// Handle other 4xx error codes.
|
||||
// Handle other 4xx error codes.
|
||||
case 500: {
|
||||
errorMsg = "Http Error Code : 500. Internal Server Error";
|
||||
break;
|
||||
}
|
||||
// Handle other 5xx error codes.
|
||||
// Handle other 5xx error codes.
|
||||
}
|
||||
errorPage.addObject("errorMsg", errorMsg);
|
||||
return errorPage;
|
||||
}
|
||||
|
||||
private int getErrorCode(HttpServletRequest httpRequest) {
|
||||
return (Integer) httpRequest
|
||||
.getAttribute("javax.servlet.error.status_code");
|
||||
return (Integer) httpRequest.getAttribute("javax.servlet.error.status_code");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,14 +14,14 @@ import com.baeldung.spring.service.RawDBDemoGeoIPLocationService;
|
|||
@Controller
|
||||
public class GeoIPTestController {
|
||||
private RawDBDemoGeoIPLocationService locationService;
|
||||
|
||||
public GeoIPTestController() throws IOException {
|
||||
locationService
|
||||
= new RawDBDemoGeoIPLocationService();
|
||||
locationService = new RawDBDemoGeoIPLocationService();
|
||||
}
|
||||
@RequestMapping(value="/GeoIPTest", method = RequestMethod.POST)
|
||||
|
||||
@RequestMapping(value = "/GeoIPTest", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public GeoIP getLocation(
|
||||
@RequestParam(value="ipAddress", required=true) String ipAddress) throws Exception {
|
||||
public GeoIP getLocation(@RequestParam(value = "ipAddress", required = true) String ipAddress) throws Exception {
|
||||
|
||||
return locationService.getLocation(ipAddress);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.springframework.web.context.support.ServletContextResource;
|
|||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.maxmind.geoip2.DatabaseReader;
|
|||
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||
import com.maxmind.geoip2.model.CityResponse;
|
||||
|
||||
public class RawDBDemoGeoIPLocationService{
|
||||
public class RawDBDemoGeoIPLocationService {
|
||||
private DatabaseReader dbReader;
|
||||
|
||||
public RawDBDemoGeoIPLocationService() throws IOException {
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.maxmind.geoip2.DatabaseReader;
|
|||
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||
import com.maxmind.geoip2.model.CityResponse;
|
||||
|
||||
|
||||
public class GeoIpIntegrationTest {
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue