org.apache.jasper.JasperException: java.lang.NumberFormatException: null

org.apache.jasper.JasperException: java.lang.NumberFormatException: null

Hello, I have created a login form which contains validations for each field. When i click on submit button function validation() will be invoked to validate all the fields and after successful validation it will redirect to another jsp page where all the details will be inserted in to the Oracle database.

But I'm getting "org.apache.jasper.JasperException: java.lang.NumberFormatException: null" exception. Also "The server encountered an internal error () that prevented it from fulfilling this request" error. I hope you will help me.

Here is the code:

userlogin:

    <html>
    <head>
    <script type="text/javascript">
    function validate()
    {

        if(document.frm.username.value=="")
        {
          alert("Please enter Username");
          document.frm.username.focus();
        }
    }


       else if(document.frm.mobile.value=="")
        {       
            alert("Please Enter your contact number");
            document.frm.mobile.focus();
        } 


    else
    {
     window.location = "insert.jsp";
    }
    </script>
    </head>

    <body>
    <form name="frm">
    <table>
    <tr><td>User Name:</td><td><input type="text" name="username"></td></tr>
    <tr><td>Contact Number:</td><td><input type="text" name="mobile"></td></tr>
    <tr><td><input type="submit" value="Submit" onclick="validate()"></td><td></td></tr>
    </table>
    </form>
    </body>

**insert.jsp:**


    <body>
             <%@page import="java.sql.*"%>
             <%@page import="java.util.*"%>
    <%
    Connection con=null;
    int mobile=Integer.parseInt(request.getParameter("mobile"));
    String username=request.getParameter("username");
    try{
         Class.forName("oracle.jdbc.driver.OracleDriver");
        con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","manager");

    Statement st=con.createStatement();
    st.executeUpdate("insert into stud values("+mobile+",'"+username+"')");
    out.println("Data is successfully inserted!");

      }

     catch(Exception e)
    {
       System.out.print(e);
    }
    %>
        </body>
View Answers









Related Tutorials/Questions & Answers:

Ads