troubleshooting Question

java.lang.NumberFormatException

Avatar of foongkim1
foongkim1 asked on
Java
6 Comments1 Solution497 ViewsLast Modified:
Hi, I have a text field for user to key in numeric input. But unfortunately user sometime want to key in "1323.00" instead of "1323".

So, when user key in "1323.00", the error, java.lang.NumberFormatException come out.

How can I avoid this exception and can I delete the ".00" at behind automatically??

form1.jsp
=========
....
.....
 <tr>
  <td width="25%"><b>**Security Amt(RM):</b></td>
  <td width="25%"><input type="text" name="secamt" maxlength=8 onKeyPress="return checkDigit(event)">
  </td>

......
......


form2.jsp
=========
....
....
 int secamt      = Integer.parseInt(request.getParameter("secamt"));
ASKER CERTIFIED SOLUTION
sajeeshb

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros