Results 1 to 2 of 2
  1. #1
    vishnuib2000 is offline Member
    Join Date
    Apr 2012
    Location
    Bangalore
    Posts
    1
    Rep Power
    0

    Default java.lang.NumberFormatException: null

    <%@ 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
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: java.lang.NumberFormatException: null

    1. Please use [code] tags [/code] when posting code, as that's unreadable without it.
    2. Don't do data access in a JSP. Do it in a servlet, or better yet in a DAO called by the servlet, and forward the data to the JSP as a business object representing that data.
    3. You might consider giving us the full exception and a best guess on your part as to where it is coming from (another reason not to use JSPs for mucking about with data like this).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. java.lang.NumberFormatException: null
    By prizzly in forum New To Java
    Replies: 2
    Last Post: 01-02-2011, 06:56 AM
  2. Replies: 5
    Last Post: 04-12-2010, 03:39 PM
  3. Exception java.lang.NumberFormatException
    By vasavi.singh in forum New To Java
    Replies: 3
    Last Post: 02-24-2009, 06:27 AM
  4. Replies: 2
    Last Post: 08-07-2007, 03:50 PM
  5. java.lang.NumberFormatException: null
    By Eric in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-05-2007, 05:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •