JSP Refactor (#3689)

This commit is contained in:
Grzegorz Piwowarek
2018-02-19 01:43:23 +01:00
committed by Predrag Maric
parent fe97d98c30
commit 0cb1447797
4 changed files with 20 additions and 64 deletions

View File

@@ -1,7 +1,6 @@
package com.baeldung.servlets;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -13,7 +12,7 @@ public class FormServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
throws IOException {
String height = request.getParameter("height");
String weight = request.getParameter("weight");
@@ -28,20 +27,17 @@ public class FormServlet extends HttpServlet {
RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/jsp/index.jsp");
dispatcher.forward(request, response);
} catch (Exception e) {
response.sendRedirect("index.jsp");
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
// do something else here
}
private Double calculateBMI(Double weight, Double height) {
return weight / (height * height);
}
}