<%--
Document : index
Created on : 12-dic-2017, 21.55.42
Author : GfO
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Quadrati da n1 a n2</title>
</head>
<body>
<h1>Quadrati da n1 a n2</h1>
<form action="index.jsp" method="get">
n1: <input name="n1" type="text">
n2: <input name="n2" type="text">
<input type="submit" value="Invia">
</form>
<%
String n1str = request.getParameter("n1");
String n2str = request.getParameter("n2");
if (n1str != null && n2str != null)
try {
int n1 = Integer.parseInt(n1str);
int n2 = Integer.parseInt(n2str);
%>
<table>
<% for (int i = n1; i <= n2; i++) { %>
<tr><td> <%=i%> </td><td> <%=i * i%> </td></tr>
<% } // end for %>
</table>
<% } catch (Exception e) { %>
<p>Devi inserire due numeri validi</p>
<% } // end try-catch %>
</body>
</html>