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 6922859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:27:40+00:00 2026-05-27T10:27:40+00:00

I made a Servlet for an online form and every time I try to

  • 0

I made a Servlet for an online form and every time I try to submit the online form, it gives me the following exception: java.lang.NumberFormatException: For input string: “”. The problem is that I don’t have any String variables in my jsp file. One more thing: when I try to fill in all the fields from the online form, the information is sent to the database, but when I try this only with some of them, it gives me that exception again. This is my code:

    import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import database.databases;

/**
 * Servlet implementation class feildsSERVLET
 */
public class feildsSERVLET extends HttpServlet
{
   private static final long serialVersionUID = 1L;

   /**
    * @see HttpServlet#HttpServlet()
    */
   public feildsSERVLET()
   {
      super();
      // TODO Auto-generated constructor stub
   }

   /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
    *      response)
    */
   protected void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
   {
      try
      {
         Class.forName("com.mysql.jdbc.Driver");
         Connection connection = DriverManager.getConnection(
               "jdbc:mysql://localhost:3306/WhizzoChocolate", "root", "");
         try
         {
            /*
             * int customerID = Integer.parseInt(request
             * .getParameter("customerID"));
             */
            int frog = Integer.parseInt(request.getParameter("frog"));

            int redspring = Integer.parseInt(request.getParameter("redspring"));
            int bluespring = Integer.parseInt(request
                  .getParameter("bluespring"));
            int silverspring = Integer.parseInt(request
                  .getParameter("silverspring"));

            int ramsquare = Integer.parseInt(request.getParameter("ramsquare"));
            int ramoval = Integer.parseInt(request.getParameter("ramoval"));
            int ramhex = Integer.parseInt(request.getParameter("ramhex"));
            int rambutt = Integer.parseInt(request.getParameter("rambutt"));

            int product_id = Integer.parseInt(request
                  .getParameter("product_id"));
            Statement statement = connection.createStatement();

            int upd = statement
                  .executeUpdate("INSERT INTO `product`(`product_id`, `RWA`, `BWA`,`SWA`, `OSA`,`SSA`,`HSA`,`BSA`)"
                        + "VALUES" + "(" + product_id
                        + frog

                        + ", "

                        + redspring

                        + ", "

                        + bluespring

                        + ", "

                        + silverspring

                        + ", "

                        + ramoval

                        + ", "

                        + ramsquare

                        + ", "

                        + ramhex

                        + ", " + rambutt + ")");

            request.setAttribute("product_id", product_id);
            request.setAttribute("frog", frog);

            request.setAttribute("redspring", redspring);
            request.setAttribute("bluespring", bluespring);
            request.setAttribute("silverspring", silverspring);

            request.setAttribute("ramsquare", ramsquare);
            request.setAttribute("ramoval", ramoval);
            request.setAttribute("ramhex", ramhex);
            request.setAttribute("rambutt", rambutt);

         }
         finally
         {
            connection.close();

         }
      }
      catch (Exception e)
      {
         throw new ServletException(e);
      }

      ServletContext context = getServletContext();
      RequestDispatcher dispatcher = context
            .getRequestDispatcher("/feildsjsp.jsp");
      dispatcher.forward(request, response);
   }

   /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
    *      response)
    */
   protected void doPost(HttpServletRequest request,
         HttpServletResponse response) throws ServletException, IOException
   {
      // TODO Auto-generated method stub
   }

}
  • 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-05-27T10:27:41+00:00Added an answer on May 27, 2026 at 10:27 am

    I’d guess that the problem is coming from one of these lines similar to this one:

    int redspring = Integer.parseInt(request.getParameter("redspring"));
    

    If the value of request.getParameter("redspring") is an empty string it will give you this exception.

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

Sidebar

Related Questions

I have this stack trace (part of) Servlet.service() for servlet action threw exception java.lang.NumberFormatException:
java.lang.NoClassDefFoundError: javax/servlet/jsp/el/ELException from using <c:set var=testVar value=testVal /> All other JSTL tags work. jsp
I have made a servlet from Jasper Reports for Java Develper (chapter 3) which
There is a html form I have which submits to a Servlet once Submit
I have a JSP form which is made of <input type=file/> tag alone for
I made a Java Applet with some Standard GUI Components on it. I used
I made a discovery some time back. Just follow these steps: Create a .doc/.xls/.ppt
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import javax.mail.*; import javax.mail.internet.*; import javax.mail.event.*; import java.net.*;
I wrote a little Java servlet that would dynamically generate an image button given
I'm maintaining a legacy Java servlet webapp ( nwp ). My goal is to

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.