inserting value

inserting value

sir i want to create a web application when we use the jsp inserting the value in the jsp after that i want these value inserted the database mySQl with the help of servlet. Inserting form data

View Answers

February 27, 2008 at 7:27 PM

Inserting form data into database using JSP and Servlet

Given code will illustrate you, how one can get data into database using JSP and Servlet

Example Code...

insertData.jsp

<html>
<head>
<title>Insert value in database</title>
</head>

<body>

<table border="1" width="50%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<h1><center>Insert value in Database</center></h1>
<form method="POST" action="InsertAction.jsp">

<table border="1" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" valign="right"><b>Name:</b></td>
<td width="50%"><input type="text" name="username" size="30"></td>
</tr>
<tr>
<td width="50%" valign="right"><b>Job-Position:</b></td>
<td width="50%"><input type="text" name="jobposition" size="30"></td>
</tr>
<tr>
<td width="50%" valign="right">&nbsp;</td>
<td width="50%" valign="right">&nbsp;</td>
</tr>
</table>
<p><input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>
</td>
</tr>
</table>
</body>
</html>
- - - - - - -
InsertAction.jsp

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


Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "register";
String driver = "com.mysql.jdbc.Driver";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
try{
Statement st = con.createStatement();
String username=request.getParameter("username");
String jobposition=request.getParameter("jobposition");
int val = st.executeUpdate("insert user_details values('"+username+"','"+jobposition+"')");
con.close();
out.println("success");
}
catch (SQLException s){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}

%>

This will help you to create a small application that will insert the HTML form data into database using JSP and Servlet.









Related Tutorials/Questions & Answers:
inserting value - JSP-Servlet
inserting value  sir i want to create a web application when we use the jsp inserting the value in the jsp after that i want these value inserted the database mySQl with the help of servlet. Inserting form data   
Inserting a value to an Enum field in Table
Inserting a value to an Enum field in Table  I'm writing a code that creates a user account and sends the result to the user table in a mysql database. For example, in the user table I have: username varchar(15) PRIMARY KEY
Advertisements
php inserting date into mysql
php inserting date into mysql  php inserting date into mysql   Here is a php code that inserts date into mysql database. In the given code... = "INSERT INTO data(dp_name, dp_date) VALUE ('DATE: Auto CURDATE()', CURDATE
inserting image into database
inserting image into database  how to insert image into database using struts frame work and spring JDBC
inserting data into datafields
inserting data into datafields  I was raised with a query.... there is a button, on click on it....... few fields regenerates and the details entered there should be inserted into Database Number of times we click that button
Inserting Data into mysql - SQL
Inserting Data into mysql  My sincere apologize for this post. I noticed there is no category for php. However am hoping my question will fit... (using php)and inserting the details in a mysql database. Lets take for instance
inserting picture in ms access
inserting picture in ms access  hi i am sanatan, how to insert picture in ms access by jsp.   <%@page import="java.sql.*,java.io.*"%>...()); pre.executeUpdate(); out.println("Inserting Successfully
duplicate records inserting
duplicate records inserting  in the application i have provided the text filed on entering and submit the record is getting inserted. my question is i want to avoid duplicate values getting inserted. ex. i am inserting name
inserting multiple file formats into database
inserting multiple file formats into database  hi i want to insert multiple file format like .pdf.doc.zip into mysql database using jsp
inserting dropdown values into database table
inserting dropdown values into database table   hi i want to insert dropdown values into a database table by using jsp
Problem in inserting clob data in jsp
Problem in inserting clob data in jsp  how to insert any rich text editor data (which have more than 32766 characters) in a clob type column of oracle database with jsp
Data is not inserting correctly in mysql database.
Data is not inserting correctly in mysql database.  Hello Sir, below is my code to insert data into database by list iteration through for loop but it is not getting inserted ..it is taking only one value
Inserting Image(s) - JSP-Servlet
Inserting Image(s)  Hello Guys, Thank you so much for your support so far. I appreciate everything you guys have done for me. Please what I wanted was java servlet or jsp codes that I can use to insert and retrieve image from MS
Inserting id in place of name to database
Inserting id in place of name to database  Hello, I have a database department where I have "id" and "name". I am fetching this data to a jsp form in dropdown list displaying "name" there and Now I wanted to insert data from
hibernate firstExample not inserting data - Hibernate
hibernate firstExample not inserting data  hello all , i followed... problem is data is not inserting into DB even though the program is executed...("inserting records in Contact table"); Contact contactBO = new Contact
Inserting content(DOM Insertion)
Inserting content(DOM Insertion)       Inserting content(DOM Insertion) Inserting Dom contents to html ,can be categories in the following 4 categories
Inserting Comma in a decimal number - Java Beginners
Inserting Comma in a decimal number  Hi, I want to insert comma... { static public void customFormat(String pattern, double value ){ DecimalFormat myFormatter = new DecimalFormat(pattern); String str = myFormatter.format(value
inserting an path of an image in database - JDBC
inserting an path of an image in database  hello kindly help related to the following issue... I m working in a project where we have to capture an image using web cam.... and when the image is saved in a project at the same
Inserting Image(s) - JSP-Servlet
Inserting Image(s)  Hello, I need sample code using java servlet and html form and explanation on how to insert and retrieve image from mysql.  Hi friend,This is insert image code.import java.sql.*;import java.io.
inserting text into text file using java application
inserting text into text file using java application  Hi, I want to insert a text or string into a text file using java application
urgent help for inserting database in a project
urgent help for inserting database in a project   I need some urgent help i have made java application for conducting a quiz which displays 25 mcq's and then the result at the end.I need to add simple database connectivity
urgent help for inserting database in a project
urgent help for inserting database in a project   I need some urgent help i have made java application for conducting a quiz which displays 25 mcq's and then the result at the end.I need to add simple database connectivity
Inserting Image into table
Inserting Image into table  In this section , we will insert a image into a table. For inserting image, table's field (in which image...)) For inserting whole image, we have to create an 'InputStream'
getting error while inserting values in database
getting error while inserting values in database  AddUser.java...; <td><input type="text" name="LASTNAME" value=""></td>..." value=""></td> </tr> <tr> <td
Inserting data in Excel File - Java Beginners
Inserting data in Excel File  Dear Sir, How can we fill the excel with fetched data from the database like Oracle, DB2? Is it possible to create an excel with filled data? Kindly give me the solutions to questions
help me in inserting data into db using hibernate
help me in inserting data into db using hibernate  How to insert data into dependent tables through hybernate   Hi Friend, Please visit the following link: http://www.roseindia.net/hibernate/insert-data-database.shtml
inserting multiple file formats into database using html
inserting multiple file formats into database using html   hi the code was working fine,i want to choose the file and then upload to database,by using html.whether it is possible to upload larger file size,please explain
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting same data to different tables in oracle
inserting same data to different tables in oracle  Hi there ...! i have to insert un,pwd, to three oracle tables, like admin, user, stud, but i want pickup these table names from a drop down list in html...is there any chance can
inserting all the values in a html table column
inserting all the values in a html table column  strong text hai everyone, i'm a fresher to servlet i need to know that, how can i insert all the values in a html table column into a database. Thanks in advance
inserting into mysql database with uid to be primary key and autoincrement
inserting into mysql database with uid to be primary key and autoincrement ...; Here is the code of inserting values from jsp form to database...;input type="submit" value="Submit"></td></tr> </table> <
by value or by reference
by value or by reference  Are objects passed by value or by reference
problem on jsp, inserting data into table(mysql).
problem on jsp, inserting data into table(mysql).  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table name also is given by the user.My database
Inserting values into a database table of selected DropDown in jsp.
Inserting values into a database table of selected DropDown in jsp.  http://www.roseindia.net/answers/viewqa/Ajax/15250-DropDown-in-ajax+jsp.html Thank you for this program, it helped me alot to learn. I have done it. now i want
Inserting data on a database in servlet - JSP-Servlet
Inserting data on a database in servlet  Hi I am following the tutorial in this site on servlet and JDBC. I did all the proccedure for connecting to a databse by a servlet.I used the example in "Inserting Data In Database table
Exception while inserting image in oracle using java
Exception while inserting image in oracle using java  import java.sql.*; import java.io.*; class Oracle2 { public static void main(String args[])throws Exception { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver
Lock while inserting/updating database in multithreaded.
Lock while inserting/updating database in multithreaded.  Hi, I am having a multithreaded process which replicates the data from many table to one... inserting/updating to database. I dont know what is the issue but it was never
inserting data from radio buttons to database - JSP-Servlet
inserting data from radio buttons to database  hi, my problem... clicks on the SUBMIT FEEDBACK button. the value of questions should insert... is the value of radio button i.e. poor,average,good. please help out here. i really
error while inserting millions of records - EJB
error while inserting millions of records  Hello, I am using ejb cmp and inserting 1 millions of records but it won't work because trancation time out occurs same problem is occur when i am using hibernate but when i am using
Inserting Text Trapezoid Using Java
Inserting Text Trapezoid Using Java       In this example we are going to create a trapezoid... are creating an object of RichTextRun constructor. In this we are passing text value
the value of $$b
the value of $$b  If the variable $a is equal to 5 and variable $b is equal to character a, what?s the value of $$b
PASS value
PASS value  javascript to pass value to other html file
Min Value
Min Value   How to access min value of column from database table?   Hi Samar, You can access minimum value of column from database...(selectQuery); System.out.println("Min Value : " +query.list().get(0
sentinel value
sentinel value  how to count the number of red cars that assume 10 cars using sentinel value
sentinel value
sentinel value  how to count the number of red cars. Assume there are 10 cars.   how to count the number of red cars that assume 10 cars using sentinel value
Hibernate hello world
In this section, you will learn about basic tutorial of inserting value in the database table and printing "hello world" on the console after successful insertion

Ads