Results 1 to 7 of 7
Thread: http500
- 11-19-2012, 09:20 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 3
- Rep Power
- 0
http500
HTTP Status 500 -
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NumberFormatException: For input string: ""
java.lang.NumberFormatException.forInputString(Unk nown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
myPack.SaveServlet.doGet(SaveServlet.java:38)
javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
Apache Tomcat/6.0.35
This is wat i get while running the project.im postin the codes here.....
form
Java Code:<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Form</title> </head> <body> <form action="SaveServlet"> First Name: <input type="text" name="firstname"><br> Last Name:<input type="text" name="lastname"><br> Email ID:<input type="text" name="email_id"><br> Phone number:<input type="text" name="phone_number"><br> Address:<input type="text" name="address"><br> Purchasing Item:<input type="text" name="purchasing_item"><br> Payment Mode: <select name="paymentment_mode"> <option>Visa</option> <option>Master</option> <option>Mastro</option> <option>Amex</option> </select><br> Card number:<input type="text" name="card_number"><br> <input type="submit" value="Save"></input> </form> </body> </html> servlet package myPack; import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class SaveServlet */ public class SaveServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * Default constructor. */ public SaveServlet() { // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String s1=request.getParameter("firstname"); System.out.println(s1); String s2=request.getParameter("lastname"); System.out.println(s2); String s3=request.getParameter("email_id"); System.out.println(s3); String s4=request.getParameter("phone_number"); int s41=Integer.parseInt(s4); System.out.println(s41); String s5=request.getParameter("address"); System.out.println(s5); String s6=request.getParameter("purchasing_item"); System.out.println(s6); String s7=request.getParameter("payment_mode"); System.out.println(s7); String s8=request.getParameter("card_number"); int s81=Integer.parseInt(s8); System.out.println(s8); String c="jdbc:mysql://localhost:3306/test"; System.out.println("Done1"); Connection con=null; try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); System.out.println("Done2"); con = DriverManager.getConnection(c, "root", "MyNewPass"); System.out.println("Done3"); PreparedStatement ps=null; System.out.println("Done4"); String qs = "insert into table1 values(?,?,?,?,?,?,?,?);"; ps = con.prepareStatement(qs); ps.setString(1,s1); ps.setString(2,s2); ps.setString(3,s3); ps.setInt(4,s41); ps.setString(5,s5); ps.setString(6,s6); ps.setString(7,s7); ps.setInt(8,s81); System.out.println("Success"); ps.execute(); con.close(); } catch (Exception e) { // TODO: handle exception System.out.println("Failed");}} protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub } }Last edited by sachi89; 11-20-2012 at 06:23 AM.
- 11-19-2012, 11:03 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: http500
Please use [code] tags [/code] when posting code.
Unformatted code is hard to read.
You are trying to parse an empty string to an Integer.
Are you actually sending anything in that field?Please do not ask for code as refusal often offends.
- 11-19-2012, 11:04 AM #3
Godlike
- Join Date
- Nov 2012
- Posts
- 195
- Rep Power
- 1
Re: http500
The answer is in the error message, for those who actually *read* the error message: For input string: "" myPack.SaveServlet.doGet(SaveServlet.java:38).
In English it says: I tried to parse a String but it was empty. This happened on line 38 of your code.
Now, go and find line 38 and find out why the parameter was empty...
- 11-20-2012, 06:28 AM #4
Member
- Join Date
- Nov 2012
- Posts
- 3
- Rep Power
- 0
Re: http500
Line 38 is
Can u pls help me out.....Java Code:String s4=request.getParameter("phone_number"); int s41=Integer.parseInt(s4);
i filled the form and while running it in eclipse the console gives,
ss
ss
zz@z.com
56464
asdcity
pen
null
22
Done1
Failed
The thing is that for the payment option its a dropdown in form and im giving the value.but still null is inserted.pls help me out....
- 11-20-2012, 09:40 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: http500
So you are no longer getting the original exception?
You have fixed that problem then?
For your payment mode, you have not given your options any values. They are all null.
Read up on the option tag.
ETA: Except, of course, it takes the value in the text...oops.
:)Last edited by Tolls; 11-20-2012 at 12:29 PM. Reason: Crappy answer.
Please do not ask for code as refusal often offends.
- 11-20-2012, 12:07 PM #6
Member
- Join Date
- Nov 2012
- Posts
- 3
- Rep Power
- 0
Re: http500
no...it was a prob with jdbc jar file!!!now its running fine!!!thanks !!!!
- 11-20-2012, 12:27 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks