Loading
View RSS Feed

Angad Kumar Shukla's blog

How To Insert Data Into Table Using JSP?

Rating: 4 votes, 2.25 average.
Click image for larger version. 

Name:	image.jpg 
Views:	12401 
Size:	14.0 KB 
ID:	191
HTML file:
Code:
<html>

<head>
    <center>INSERT INTO TABLE</center>
</head>

<body bgcolor="bisque" text="green">
    
    <center>

    <form name="f" method="post" action="5.jsp">

    Enter the name:   <input type="text" name="n1"><br><br>

     Enter the roll no:   <input type="text" name="n2"><br><br>

       Enter the marks:   <input type="text" name="n3">
    <br><br> 
    <input type="submit" value="insert">

    </form>
    
    </center>

</body>

</html>
JSP file:
Code:
<html>

<head>
        
</head>

<body>
    <%@page language="java"%>
    <%@page import="java.sql.*"%>

    <%

        String s1=request.getParameter("n1");
        int s2=Integer.parseInt(request.getParameter("n2"));
        int s3=Integer.parseInt(request.getParameter("n3"));
        

        PreparedStatement ps=null;
        Connection cn=null;
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        cn=DriverManager.getConnection("jdbc:odbc:j1");
        ps=cn.prepareStatement("insert into student1 values(?,?,?)");
        ps.setString(1,s1);
        ps.setInt(2,s2);
        ps.setInt(3,s3);
        ps.executeUpdate();
        out.println("insertion done");
    %>

</body>


    
    
    </html>

Submit "How To Insert Data Into Table Using JSP?" to Digg Submit "How To Insert Data Into Table Using JSP?" to del.icio.us Submit "How To Insert Data Into Table Using JSP?" to StumbleUpon Submit "How To Insert Data Into Table Using JSP?" to Google

Comments

  1. chikoo's Avatar
    nicely done. clear cut. liked it.



Disclaimer: Users of techforum4u.com are responsible for ensuring that any material they post (article, blog posts, images or other mulitimedia content) does not violate or infringe upon the copyright, patent, trademark, or any personal or proprietary rights of any third party, and is posted with the permission of the owner of such rights.Anyone who violates these rules may have their access privileges removed without warning.