JSP Refactor (#3689)
This commit is contained in:
committed by
Predrag Maric
parent
fe97d98c30
commit
0cb1447797
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user