0

Hi I wish to get a users age from a form and convert that String to an int and use elsewhere in a java class

The .jsp snippet looks like this

    <% 
    String str = request.getParameter("age"); 
    int convertInt = Integer.parseInt(str); 
    %>

    <% myProgram.comAvgerage(convertInt);%>

however i am getting HTTP Status 500 - java.lang.NumberFormatException: null

I think this is because the form is being created in a UI class first thus the fields are null ?

Is this the fault and can i fix this thanks

Paul Hicks
  • 13,289
  • 5
  • 51
  • 78
Aaron
  • 75
  • 8

1 Answers1

0

This suggests that request.getParameter("age") is returning null. This means that there is no parameter called "age" being submitted via the form. Check to make sure "age" is the name of your form parameter. ie. input type="text" id="parameter" name="age" value="test"

They must match make sure the cases match too.

brso05
  • 13,142
  • 2
  • 21
  • 40