diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/ru/erius/weblab2/controller/AreaCheckServlet.java b/src/main/java/ru/erius/weblab2/controller/AreaCheckServlet.java index e0eb219..e468254 100644 --- a/src/main/java/ru/erius/weblab2/controller/AreaCheckServlet.java +++ b/src/main/java/ru/erius/weblab2/controller/AreaCheckServlet.java @@ -31,11 +31,21 @@ public class AreaCheckServlet extends HttpServlet { timezoneOffset = 0; } + String xParam = req.getParameter("xValue"), yParam = req.getParameter("yValue"), + rParam = req.getParameter("rValue"); + if (xParam == null || yParam == null || rParam == null) { + resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "X, Y or R is not defined"); + RequestDispatcher rootDispatcher = req.getRequestDispatcher("/"); + rootDispatcher.forward(req, resp); + return; + } + float x, y, r; try { - x = Float.parseFloat(req.getParameter("xValue")); - y = Float.parseFloat(req.getParameter("yValue")); - r = Float.parseFloat(req.getParameter("rValue")); + + x = Float.parseFloat(xParam); + y = Float.parseFloat(yParam); + r = Float.parseFloat(rParam); } catch (NumberFormatException e) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "X, Y and R must be numeric"); RequestDispatcher rootDispatcher = req.getRequestDispatcher("/");