<!DOCTYPE html>
<html>
<head>
<title>MVC Servlet</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h2>Solar System</h2>
<form action="Result" method="get">
<p>How many planets you want to enter:<input type=number name=numberOfPlanets ></p>
<input type="submit" value="Enter" />
</form>
</body>
</html>
@WebServlet("/Result")
public class Kontroler extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String numberOfNewPlanets = request.getParameter("numberOfPlanets");
int numberOfPlanets = Integer.parseInt(numberOfNewPlanets);
PrintWriter out = response.getWriter();
String htmlRespone = "<html>";
htmlRespone += "Your numberOfPlanets is: " + numberOfPlanets + "<br/>";
htmlRespone += "</html>";
out.println(htmlRespone);
}
}