java.lang.Numberformatexception: null

Asked

Viewed 192 times

-3

I’m getting the following error: java.lang.NumberformatException: null; My code:

<%! int a; %>
<%! int b; %>
<%
String getTest = request.getParameter("testJava");

System.out.println(getTest);

%>

<% int b = Integer.parseInt(request.getParameter("testJava"));  %>

<%
for(int a = 0; a <= b; a++){

System.out.println(getTest);

}
%>

1 answer

0

request.getParameter("testJava") is returning null.

With that the method parseInt() tries to convert null for an integer number, fails and throws the exception.

One way to deduce this is through the name of the exception that suggests the meaning "exception in number format".

Can also be checked in the method documentation Integer.parseint().

Browser other questions tagged

You are not signed in. Login or sign up in order to post.