Why do I get error with glassfish and netbeans?

0

And I really do not know what's wrong. This is the code: index.html

<!DOCTYPE html>

<html>
    <head>
        <title>Todo supply a tittle</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
    <form name= "frmDatos" action="pagina1.jsp" method="get">
        <b>Formulario</b>
        <br>
        Nombre:<input type="text" name="txtNombre" value="" />
        <br>
        Apellido:<input type="text" name="txtApellido" value="" />
           <br>
        Numero:<input type="text" name="Numeor" value="" />
        <br>
        <input type="submit"  value="mostrar" name="btnMostrar" />
    </form>        
    </body>
</html>


**pagina1.jsp**

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<% 
    String nombre  = request.getParameter("txtNombre");
    String apellido  = request.getParameter("txtApellido");
    int n = Integer .parseInt(request.getParameter("txtNumero"));
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Datos Pagina</h1>
        <br>
        Nombre:<%=nombre%>
        <br>
        Apellido:<%=apellido%>
        <br>
        Listado de numeros:
        <%for (int x = 1; x < n; x++) {%>
        <br>
        Numero= <%=x%>
        <br>
        <%}%>
    </body>
</html>

But now I get this error

    
asked by Gerardo Guevara 20.08.2018 в 06:39
source

1 answer

1

You are sending the name of a parameter incorrectly. In the url you have Numeor=2 , but in the html you have request.getParameter("txtNumero") .

This way, when you get null you get the error you put.

Fix the url so that it sets txtNumero=2 and solved.

    
answered by 20.08.2018 / 09:48
source