Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet org.apache.jasper.JasperException: java.lang.NumberFormatException:
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Bhavya
org.apache.jasper.JasperException: java.lang.NumberFormatException:
0 Answer(s)      a year and 8 months ago
Posted in : JSP-Servlet


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:

<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>

Advertisement
View Answers

Related Tutorials/Questions & Answers:
 

 

 

DMCA.com