0

if i hit sumbit i get output at bottom. but if i check again than i get a error. bc number1 is null.
i was thinking to have about if statment inside if statment, to text if int field is null or not.

<html>
<body>

<!-- directive tag -->
<%! String username;
    int number1 = 0;
%>
<br/><br/><br/>


 <form method="post" action="index.jsp">
    what's your name?<br/>
    <input type="text" name="usernameField"/><br/>
    what's your aga?<br/>
    <input type="text" name="ageField" /><br/>
    <input type="submit" name="submit" />
</form>


<%
if (request.getParameter("submit") != null) {
    username = request.getParameter("usernameField");
    number1 = Integer.parseInt(request.getParameter("ageField"));
    out.print("answer" + number1);
}
%>

</body>
</html>

Edited by peter_budo: Moved to JSP section

1
Contributor
1
Reply
11
Views
4 Years
Discussion Span
Last Post by game06
0

ops i just figue it out.

i just had question, how do i see if number1 is null.
i was thinking number == 0 but thats not null. its zero.

int number1 = Integer.parseInt(request.getParameter("ageField"));

i tried this but non of them works:

 if(request.getParameter("ageField").equals(""))
  if(request.getParameter("ageField") == null)
   if(number = null)

Edited by game06

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.