Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8507833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:58:53+00:00 2026-06-11T02:58:53+00:00

Getting an NumberFormat exception from a form submission that passes a phone number. However,

  • 0

Getting an NumberFormat exception from a form submission that passes a phone number. However, the number passed is in fact a number and I convert it to an int within the servlet. Within the error message you can see that an int was entered in – 8456640236.

Servlet Method

public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
    Contact newComment = new Contact();

    newComment.setName(request.getParameter("nameParameter"));
    newComment.setEmail(request.getParameter("emailParameter"));
    newComment.setPhone(Integer.parseInt(request.getParameter("phoneParameter")));
    newComment.setComment(request.getParameter("commentParameter"));

    request.setAttribute("commentAttribute", newComment);

    RequestDispatcher view = request.getRequestDispatcher("/successComment.jsp");
    view.forward(request, response);
}

Error Message

java.lang.NumberFormatException: For input string: "8456640236"
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
java.lang.Integer.parseInt(Integer.java:461)
java.lang.Integer.parseInt(Integer.java:499)
org.test.Servlet.doPost(Servlet.java:21)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:58:54+00:00Added an answer on June 11, 2026 at 2:58 am

    The value you’re trying to parse is larger than an Integer can hold, 231-1, which is 2147483647.

    You’d need to make it a Long (or long) instead and use Long#parseLong() to parse it.

    newComment.setPhone(Long.parseLong(request.getParameter("phoneParameter")));
    

    Note that this concrete problem has nothing to do with JSP/Servlets, but anything with basic Java. You’d have exactly the same problem when doing so in a plain vanilla Java class with a main() method and hardcoded values (which would have been easier for you to isolate the problem).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting a number format exception when trying to do it int temp
I am trying to convert to int like this, but I am getting an
I am trying to get an int from an edit text set to inputType=number
I am trying to convert string to double. But i am getting the number
Getting an Undefined Offset error here -- apparently from the $newval array. Note that
Getting red warning message that expected identifier for this statement CALayer = ImageView.layer; Using
I'm getting the error Exception in thread main java.lang.NumberFormatException: For input string: scores.txt at
I'm getting a NumberFormatException on the Integer.parseInt() method. I know this exception is produced
I am getting a force close when there is Int on my edittext and
I am getting an error because of the following line of code: int x

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.