Home Answers Viewqa JSP-Servlet getting int values from form and insert it in data base in jsp

 
 


mahmoud
getting int values from form and insert it in data base in jsp
2 Answer(s)      2 years and 5 months ago
Posted in : JSP-Servlet

how can i get form input such as id convert it to int insert it into database

View Answers

December 26, 2010 at 7:35 PM


Hi,

You can get the parameter from the request object:

String s = request.getParameter("formfieldname");

Then convert it into Integer variable:

int i = Integer.parseInt(s);

Then you can write JDBC code to insert data into database.

Read JDBC Insert Statement Example for more detail.

Thanks


December 27, 2010 at 10:57 AM


Hi Friend,

Try the following code:

1)form.jsp:

<%@page import="java.sql.*"%>
<html>
<form method="post" action="insertdata.jsp">
<table>
<tr><td>Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Age:</td><td><input type="text" name="age"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)insertdata.jsp:

<%@page import="java.sql.*"%>
<%
String name=request.getParameter("name");
int age=Integer.parseInt(request.getParameter("age"));
String address=request.getParameter("address");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con = DriverManager.getConnection("jdbc:odbc:student");
           Statement st=con.createStatement();
           int i=st.executeUpdate("insert into data(name,age, address) values('"+name+"',"+age+",'"+address+"')");
         con.close();
         out.println("Data is successfully inserted into database.");
}
catch(Exception e){
    System.out.println(e);

}
         %>

Thanks









Related Pages:
getting int values from form and insert it in data base in jsp
getting int values from form and insert it in data base in jsp  how can i get form input such as id convert it to int insert it into database  ...=st.executeUpdate("insert into data(name,age, address) values('"+name+"',"+age
JSP data base validation
JSP data base validation  please explain how to validate form input string with database n also how its notify that entered data exists already... into student2(id, sName, phno) values(?,?,?)"; String sql2 = "select * from student2
insert excel value in to oracle data base
insert excel value in to oracle data base  Hi All I am using... the data from the excel file using JDBC. For this you need to create dsn... org.apache.poi.hssf.usermodel.HSSFCell@19360e2 i am not getting right value... my code
value is inserted into the sql table through jsp-jdbc but not getting stored into the data base,only row is increasing.
value is inserted into the sql table through jsp-jdbc but not getting stored into the data base,only row is increasing.  <html> <... ="INSERT INTO demodb VALUES('"+name+"','"+email+"','"+password
how to insert the bulk data into the data base from the table of jsp page to another jsp page
how to insert the bulk data into the data base from the table of jsp page... to insert the marks details into the data base i have retrive the rollno and name... to get values in array in next jsp page and insert into the row by row Please do
insert data
and as well as the passed data from mulitpart/form-data is greater than or equal to 0...insert data  i've got a problem to insert my data to database.i can...("insert into images values(?,?,?,?,?)"); st.setString(2
insert values - JSP-Servlet
insert values  How to insert values in the oracle database using JSP...;insert user_details values('"+username+"','"+jobposition+"... page<html><head><title>Insert value in database</title><
how to get a values from a multipart/form-data - JSP-Servlet
how to get a values from a multipart/form-data  Dear sir , I used your code for getting a values,i used the fllowing function... ,matter,file field values but not status and from field i am getting null
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
Data base - JDBC
= con.prepareStatement( "insert into personaldetails(empno,photo,permanent_address) values...Data base  I want to do this Inserting a record with Object type... want to insert null in place of Present Address ps.setInt(1,7934); File
DATA BASE
:3306/test", "root", "root" ); String sql = "Select name,address from data... = new JTable(data, columnNames); TableColumn col; for (int i = 0; i <...DATA BASE  Create a program to establish a connection to the PCTBC
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please help me , i have on GUI page int that Server type(like apache,jboss,weblogic) one... of the server it has to display the process name from database into the process name
How to insert data into databse by JSP form registration page in netbeans
How to insert data into databse by JSP form registration page in netbeans  ... of data for login purpose. I have created 1 form in JSP netbeans with both username...; password, & after submitting this form it automatically stores data
what is the jsp coding to insert a data in database tables
what is the jsp coding to insert a data in database tables  Dear Sir, I Want to know the coding for insert the data from jsp to oracle database.. my... that insert the form values to MySQL database. 1)register.jsp: <html> <form
for store data in data base - JSP-Servlet
.. and on 3rd form i use submit button... data of form 1 and 2 can also be store...for store data in data base  i want to a job site, in this site user can registered by a form.. in this form there are his information... i use
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what... = null; // declare a resultset that uses as a table for output data from... = 0; // sql query to retrieve values from the specified
database is connected but not insert the data
database is connected but not insert the data  hi, i am getting connected to database.Retrive the data also but cannot insert the data into database...=con.prepareStatement("insert into studentmaster(slno) values('"+batch+"')"); i
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file... of the ArrayList in jsp in a tabular form/way. if (request.getParameter("action
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp?  Hi, I need help in jsp to display values of an ArrayList in jsp. There is a java file... of the ArrayList in jsp in a tabular form/way. if (request.getParameter("action
getting and storing dropdown list in database in jsp
","root"); Statement st=con.createStatement(); int i=st.executeUpdate("insert into data(language) values('"+selectedValue+"')"); out.println("Data...getting and storing dropdown list in database in jsp  i have a drop
disable the form - JSP-Servlet
Multiple form are created in Jsp. Servlet is used to insert the data. Ajax is used... wrote jsp page in that 8 forms are there.all forms are same but the input values... Ajax. after response is coming to the jsp page,particular form button
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... ,update,delete database values from jtable only so i added three buttons add,update... an UPDATE or an INSERT int numNewRows = newRows.size(); int
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... ,update,delete database values from jtable only so i added three buttons add,update... an UPDATE or an INSERT int numNewRows = newRows.size(); int
jsp form
jsp form  hi i have one excuted jsp form.and in that the data should be dispaly on another jsp form.please help me thanks in advance   Hi... values from previous page</h3> <form> <table> <tr><td>
getting values from database - JSP-Servlet
getting values from database  I tried the following code abc.html aaa.jsp I am not getting exceptions now... JSP code separately.If it will not display database values then try your code
how to insert values from jsp into ms access
how to insert values from jsp into ms access   how to insert values using jsp into ms access database
Data base related question
Data base related question  sir my table has only one element... csee my code import java.sql.*; class raja { int regd1; public int k() { try...:odbc:oldp"); stmt2=con2.createStatement(); String st2="select * from pname order
Servlet to add the data into database
the data in the database table from a html form.  This servlet program..., clicking on which the values will be passed to the server. The data entered from the HTML form will be retrieved by the server side program i.e. servlet. 
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
how to insert data into databasse by using jdbc
how to insert data into databasse by using jdbc  â?¢ Create a Registration Form with 10 input fields using HTML and get those inputs using JSP and insert those inputs into database using JDBC.   Here is a jsp code
want to insert values in drop down menu in struts1.3
want to insert values in drop down menu in struts1.3  I am using DynaValidatorForm.please help me with inserting values in color drop down menu. I...="org.apache.struts.validator.DynaValidatorForm"> <form-property type="int" name="id" initial
insert data in the database using checkbox
insert data in the database using checkbox  i am fetching data from... should i insert only checked data into database on submission.   We...("select * from book"); int i=0; while(rs.next()){ %> <tr><td><
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  hello!!! I am building a attendance sheet in which, I am getting data from one jsp form and want inserting it into my mysql database table. but i am having
Insert Data From File
Insert Data From File       Insert Data From File is  used to insert data from file... to insert data from file. To understand this example, we create a table 'Stu_Table
retrive record from the text field and insert into to database
retrive record from the text field and insert into to database  the following code is inserting values in the my sql database but i want to insert... getting followinng error "ORA-00926: missing VALUES keyword
Insert image from user using and save in database
= connection.prepareStatement("insert into file(file_data) values(?)"); fis = new...Insert image from user using and save in database  when i am trying...="multipart/form-data" ACTION="upload.jsp" METHOD=POST> <br><br><
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
data base
data base  how to connect coding in data base ?   The given code connects JSP page to database. You need to import the mysql connection jar file to jdk as well as to the lib of tomcat. Moreover you need to set classpath
how to insert, retrieve data from,to db(code)....
how to insert, retrieve data from,to db(code)....  Hi..... i ve... that data will b stored in db(m using sybase). 2.also hw to retrieve the data from.../javascriptpagerefresh.shtml http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml
Getting file size - JSP-Servlet
and as well as the passed data from mulitpart/form-data is greater than or equal to 0...Getting file size  Hello friends, I am doing a jsp project... type information from JSP Request Header String contentType
Pass values from form to form
Pass values from form to form       Java program to pass values from one form to another form... values from one page to another consecutive page which is being called then we can
Java Multiple Insert Query
example that demonstrates how to execute the multiple sql insert query in JSP.... Then I have created the two JSP pages one for getting the value... the multiple selected items from the dropdown list into the JSP page I have use
how to insert, retrieve data from,to db(code)....
how to insert, retrieve data from,to db(code)....  Hi, i have created login page n in that a registration form also in jsp, my doubt is-when new user... will b stored in db(m using sybase). 2.also hw to retrieve the data from db. cn u
Insert data in Excel File from Database using JSP
Insert data in Excel File from Database  using JSP ... developed a application to insert data  in excel file from database in JSP. We... the data from database, create an excel file and data insert into newly
how to display data from jsp file into database
how to display data from jsp file into database  this is a jsp file...(); in the below example. the error is "cannot convert from java.sql.Statement... import="java.sql.*"%> Insert title here <% String t

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.