Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: (java.lang.NumberFormatException: null) error

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Location
    Raichur
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post (java.lang.NumberFormatException: null) error

    I'm getting error java.lang.NumberFormatException: null while running my project please help me

    the following is the code


    <%@ page import="java.sql.* , java.util.*" %>




    <html>
    <head>
    <title>Insurance::Add new policy</title>
    <script language="javascript" type="text/javascript">
    <!--
    var win=null;
    function NewWindow(mypage,myname,w,h,scroll,pos){
    if(pos=="random"){LeftPosition=(screen.width)?Math .floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Mat h.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){LeftPosition=(screen.width)?(scr een.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
    settings='width='+w+',height='+h+',top='+TopPositi on+',left='+LeftPosition+',scrollbars='+scroll+',l ocation=no,directories=no,status=no,menubar=no,too lbar=no,resizable=no';
    win=window.open(mypage,myname,settings);}
    // -->
    </script>
    <script language="javascript" type="text/javascript" src="../../js/validation1.jsp">
    </script>
    <script language="javascript" type="text/javascript">
    function checkAll()
    {
    check_null("name","Person Name");
    check_null("address","Address");
    check_date();
    if(str=="Please Check the following \n")
    {
    return true;
    }
    else
    {
    alert(str);
    str="Please Check the following \n";
    return false;
    }
    }
    </script>
    </head>
    <body>
    <a href="index.jsp">Home</a>&nbsp;|&nbsp;<a href="javascript: window.history.back();">Back</a>
    <h1 align="center">Add New Policy</h1>
    <div style="color:red;" align="center">
    <%
    Enumeration e = request.getParameterNames();
    int j=0;
    while (e.hasMoreElements())
    {
    String name = (String)e.nextElement();
    if(name.equals("msg"))
    {
    j= Integer.parseInt(request.getParameter(name));
    }
    }
    String arr[] ={"","<font color='green'>The values successfully inserted</font>","Please Login before proceeding"};
    out.println(arr[j]);
    %>
    </div>
    <form action="Action/add_new_policy.jsp" method="post" onSubmit="return checkAll()">
    <table width="70%" border="0" align="center">
    <tr bgcolor="#dddddd">
    <td>User Id</td>
    <td><input name="user_id" type="text" size="35" maxlength="35"></td>
    </tr>
    <tr bgcolor="#dddddd">
    <td>Total Amount to pay</td>
    <td><select name="amt" id="amt">
    <option value="50000">50000</option>
    <option value="100000">100000</option>
    <option value="200000">200000</option>
    <option value="300000">300000</option>
    <option value="400000">400000</option>
    <option value="500000">500000</option>
    <option value="600000">600000</option>
    <option value="700000">700000</option>
    <option value="800000">800000</option>
    </select></td>
    </tr>
    <tr bgcolor="#dddddd">
    <td>Plane Type:</td>
    <td>
    <%
    try{
    Class.forName("com.mysql.jdbc.Driver").newInstance ();
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/INSURE", "root", "root");
    PreparedStatement ps=con.prepareStatement("select plan_name from plan_info");
    ResultSet rs=ps.executeQuery();

    %>
    <select name='name'>

    <%

    while(rs.next())
    {
    %>
    <option><%=rs.getString(1)%></option>


    <% }
    }catch(Exception exc)
    {
    out.println(exc);
    }
    %>
    </select>

    </td>
    </tr>
    <tr bgcolor="#dddddd">
    <td>Duration</td>
    <td>
    <select name="duration">
    <option value="5">5</option>
    <option value="8">8</option>
    <option value="10">10</option>
    <option value="15">15</option>
    </select>
    </td>
    </tr>
    <tr bgcolor="#dddddd">
    <td>Payment Duration:</td>
    <td>
    <select name="payment_duration">
    <option value="yearly">Yearly</option>
    <option value="half_yearly">Half-yearly</option>
    <option value="monthly">Monthly</option>
    </select>&nbsp;<a href="premium_calculator.jsp" target="myWindow" >Calculate Premium Amount</a>
    </td>
    </tr>
    <tr>
    <td colspan="2"><b>Insuring Life of/b></td>
    </tr>
    <tr bgcolor="#dddddd">
    <td>Person Name:</td>
    <td><input name="name" id="name" type="text" size="20" maxlength="35" /></td>
    </tr>
    <tr bgcolor="#dddddd">
    <td>Date of Birth</td>
    <td>
    <select name="date" id="date">
    <%
    for(int i=1;i<=31;i++)
    {
    out.println("<option value='"+i+"'>"+i+"</option>");
    }
    %>
    </select>
    <select name="month" id="month">
    <%
    for(int i=0;i<12;i++)
    {
    out.println("<option value='"+i+"'>"+(i+1)+"</option>");
    }
    %>
    </select>
    <select name="year" id="year">
    <%
    for(int i=2009;i>=1900;i--)
    {
    out.println("<option value='"+i+"'>"+i+"</option>");
    }
    %>
    </select>
    </td>
    </tr>
    <tr bgcolor="#dddddd">
    <td>Address</td>
    <td><textarea name="address" id="address" cols="20" rows="5"></textarea></td>
    </tr>
    <tr>
    <td><input name="" type="submit" value="Submit" /></td>
    <td><input type="reset" value="Reset" /></td>
    </tr>
    </table>

    </form>
    </body>
    </html>


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,606
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: (java.lang.NumberFormatException: null) error

    What line generates the error?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Java Error cannot be applied to (java.lang.String), phone book entry program.
    By iceyferrara in forum What's Wrong With My Code?
    Replies: 5
    Last Post: September 23rd, 2011, 07:32 AM
  2. java.lang.IllegalArgumentException: im == null!
    By simantoch in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: April 10th, 2011, 03:15 PM
  3. java.lang.numberformatexception error
    By natalie in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 19th, 2010, 04:16 AM
  4. Replies: 1
    Last Post: January 15th, 2010, 01:32 AM
  5. Replies: 2
    Last Post: November 3rd, 2009, 06:28 AM

Tags for this Thread