jsp - How do I fix a java.lang.NumberFormatException: for String " " in my servlet? -


"itemprop =" text ">

After I parse a string parameter in an integer I pulled from a corresponding jsp and after trying to create them, in the same error The display continues and a float in my web application I have Java class, the one on which I am trying to parse is an integer and a float, but I can not find a way to parse and work my servlet By the way i am I'm so proud. Here the code I used in my servlet is: Get the parameter from

  // newStudentPage.jsp string id = request.getParameter ("stuId"), string fName = request.getParameter (" FName "); String lName = request.getParameter ("lName"); String road = request.getParameter ("street"); String city = request.getParameter ("city"); String position = request.getParameter ("state"); String zip = request.getParameter ("zip"); String email = request.getParameter ("email"); String gpa = request.getParameter ("GPA"); Int zip = integer.valof (zip); Float GPA = Float. PRS Flat (GPA); // request a request dispatcher to forward the request of jsp to the despter rd = request.getRequestDispatcher ("newStudentLoginPage.jsp"); Request Dispatcher rd2 = request.getRequestDispatcher ("newStudentSectionAddDrop.jsp"); // Create Student Object and fill with Paramater Data Student S2 = New Student (); S2.setstuId (id); S2.setfName (fName); S2.setlName (lName); S2.setstreet (road); S2.setcity (city); S2.setstate (state); S2.setzip (zip); S2.setemail (email); S2.setgpa (GPA); // Keep student object in session Http session ses2 = request.getSession (); Ses2.setAttribute ("s2", s2); If (id.equals ("") || fName.equals ("") || lName.equals ("") || street.equals ("") || city.equals ("") || state.equals ("") || zip.eimals ("") || email. Angle ("") || GPAiagles ("")) {rd.forward (request, response); } And (rd2.forward (request, response);}  

Does anyone give me some insights into doing something wrong?

One or all of the rows can create exceptions:

  int zip = integer.wooof (zip); float GPA = Float. PRSFLOT (GPA);  

You have to see whether the string zip or GPA can always be converted to a number or not, what if the user Nothing enters into the code like "7777", "" , "" or non-number ? Due to those conditions a < Code> NumberFormatException will


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -