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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.