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.

View Answers

April 23, 2012 at 4:07 PM

1)form.jsp:

<html>
<body>
<form method = "post" action = "/Examples/GetParameterValues">
<p>Which of the programming languages you like the most</p>
<select name="lang">
<option value="C/C++">C/C++</option>
<option value="Java">C/C++</option>
<option value=".NET">C/C++</option>
<option value="Perl">C/C++</option>
<option value="Pascal">C/C++</option>
</select>
</form>
</body>
</html>

2)GetParameterValues

import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;

    public class GetParameterValues extends HttpServlet{
      protected void doPost(HttpServletRequest request, 
       HttpServletResponse response)
     throws ServletException, IOException {
    String languages=" ";
      response.setContentType("text/html");
      PrintWriter pw = response.getWriter();
      String[] lang = request.getParameterValues("lang");
      for(int i=0; i<lang.length; i++){
      lanuages+=lang[i]+" ";
      }
    try{
    Class.forName("com.mysql.jdbc.Driver").newInstance();
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root" );
            Statement st=conn.createStatement();

                 st.executeUpdate("insert into data(languages) values('"+languages+"')");
                pw.println("Inserted Successfully!");
            }
    catch(Exception e){}
      }
    }

April 23, 2012 at 4:08 PM

1)form.jsp:

<html>
<body>
<form method = "post" action = "/Examples/GetParameterValues">
<p>Which of the programming languages you like the most</p>
<select name="lang" multiple>
<option value="C/C++">C/C++</option>
<option value="Java">C/C++</option>
<option value=".NET">C/C++</option>
<option value="Perl">C/C++</option>
<option value="Pascal">C/C++</option>
</select>
</form>
</body>
</html>

2)GetParameterValues

import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;

    public class GetParameterValues extends HttpServlet{
      protected void doPost(HttpServletRequest request, 
       HttpServletResponse response)
     throws ServletException, IOException {
    String languages=" ";
      response.setContentType("text/html");
      PrintWriter pw = response.getWriter();
      String[] lang = request.getParameterValues("lang");
      for(int i=0; i<lang.length; i++){
      lanuages+=lang[i]+" ";
      }
    try{
    Class.forName("com.mysql.jdbc.Driver").newInstance();
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root" );
            Statement st=conn.createStatement();

                 st.executeUpdate("insert into data(languages) values('"+languages+"')");
                pw.println("Inserted Successfully!");
            }
    catch(Exception e){}
      }
    }

April 23, 2012 at 4:12 PM

1)form.jsp:

<html>
<body>
<form method = "post" action = "insert.jsp">
<p>Which of the programming languages you like the most</p>
<select name="lang" multiple>
<option value="C/C++">C/C++</option>
<option value="Java">C/C++</option>
<option value=".NET">C/C++</option>
<option value="Perl">C/C++</option>
<option value="Pascal">C/C++</option>
</select>
</form>
</body>
</html>

2)insert.jsp

<%@page import="java.io.*"%>

<%@page import="java.sql.*"%> <% String languages=" "; String[] lang = request.getParameterValues("lang"); for(int i=0; i


April 23, 2012 at 4:13 PM

1)form.jsp:

<html>
<body>
<form method = "post" action = "insert.jsp">
<p>Which of the programming languages you like the most</p>
<select name="lang" multiple>
<option value="C/C++">C/C++</option>
<option value="Java">C/C++</option>
<option value=".NET">C/C++</option>
<option value="Perl">C/C++</option>
<option value="Pascal">C/C++</option>
</select>
</form>
</body>
</html>

2)insert.jsp

  <%@page import="java.io.*"%>
     <%@page import="java.sql.*"%>
            <%
              String languages=" ";
              String[] lang = request.getParameterValues("lang");
              for(int i=0; i<lang.length; i++){
              lanuages+=lang[i]+" ";
              }
            try{
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root" );
            Statement st=conn.createStatement();
            st.executeUpdate("insert into data(languages) values('"+languages+"')");
            out.println("Inserted Successfully!");
                    }
            catch(Exception e){}
              %>









Related Tutorials/Questions & Answers:
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
Inserting values into a database table of selected DropDown in jsp.
Inserting values into a database table of selected DropDown in jsp.  ... to insert all selected values in data base correspondent to each like if user selected india and then goa. I want to insert it to a table which has two fields
Advertisements
Inserting values in MySQL database table
Inserting values in MySQL database table   ... the facility for inserting the values in MySQL database table. Description... InsertValues Inserting values in Mysql database table! 1 row
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
store dropdown box values in database server
store dropdown box values in database server  how to store dropdown box values in database server in jsp
getting error while inserting values in database
getting error while inserting values in database  AddUser.java... into LTCINFO.PERSONS values ('"+LASTNAME+"','"+FIRSTNAME+"','"+ADDRESS+"','"+CITY...) { out.println("An Error Had occurred while accessing the database
Inserting Image in Database Table
Inserting Image in Database Table   ... hibernatetutorial, in our case. This database has a table (Image table). For inserting... to the MySQL database table.  Flow of the process
fetch values in dropdown
fetch values in dropdown  in my application i want fetch dropdown values in jsp page through servlet. means i have to fetch the database fields values in array variable of servlet and then i have to print those values in dropdown
how to display values from database into table using jsp
how to display values from database into table using jsp  I want to display values from database into table based on condition in query, how... the values from database based on the bookname or authorname entered must be display
Query to insert values in the empty fields in the last row of a table in Mysql database?
Query to insert values in the empty fields in the last row of a table in Mysql database?  I have some fields filled and some fields empty in the last row of my MYSQL database. Now I want to fill up those empty fields in the last
Inserting id in place of name to database
Inserting id in place of name to database  Hello, I have a database... in dropdown list displaying "name" there and Now I wanted to insert data from this form to another table and in place of "name" of department I wanted to insert
how can i store text box values as it is in database table
how can i store text box values as it is in database table  CUSTOMER DESCRIPTION
ajax+dropdown+table format
ajax+dropdown+table format  HI, i am looking for an ajax application which must contain two dropdown list.In first dropdown if i select a manager name from the first dropdown all the reporties under the selected manager should
Inserting Data In Database table using Statement
Inserting Data In Database table using Statement... into the table so we need to write a query for inserting the values into the table... to insert the data in the database from our java program in the table stored
getting values from dropdown list
getting values from dropdown list  I am having a dropdown list which has hardcoded values ( we need it hardcoded only and will not be populated from the database) My question is when i select a particular value it should be pass
inserting image into database
inserting image into database  how to insert image into database using struts frame work and spring JDBC
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
reading dropdown values from properties file in jsp
reading dropdown values from properties file in jsp  reading dropdown values from properties file in jsp
How to Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database(MySql)?
) and save the new position (values) also in database(MySql)?  Hi members, I have one Html table in jsp page and i am iterating values (in columns of html table)from Database, Now i am Dragging and dropping one HTML table row to another
Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database
table in jsp page and i am iterating values (in columns of html table)from Database, Now i am Dragging and dropping one HTML table row to another position.I...Dragging and dropping HTML table row to another position(In Jsp) and save
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
disallow NULL values in a table.
disallow NULL values in a table.  How do I disallow NULL values in a table
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 will be stored) must be define as "blob". First, Create table'inImage'
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
How to display all the Select values from the MySQL database table in where condition= In JSP?
How to display all the Select values from the MySQL database table in where... to display all the select values from MySQL DB** only first value is displayed in the jsp file. @select * from table dept where dept_no=10;" jsp code i have used
Inserting data on a database in servlet - JSP-Servlet
to a databse by a servlet.I used the example in "Inserting Data In Database table...Inserting data on a database in servlet  Hi I am following... of a table,that is none of the data which i tried to enter into database by using
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...,cdrcost) values ('" + calldate + "','" + clid + "','" + src + "','" + dst
jsp- database dependent dropdown list
jsp- database dependent dropdown list   i want 2 dropdown list 1- CLASS 2-SECTION both are should come from database. and if i select a class...; For the above code, we have created two database tables: CREATE TABLE `country
Dropdown code to retrieve result from oracle database
values from the database into dropdown. As the user choose any option from the dropdown, corresponding values will get displayed in the textboxes...Dropdown code to retrieve result from oracle database  Hi Friends, I
jsp -sevlet connecting to database using dropdown
jsp -sevlet connecting to database using dropdown  How can I get my dropdown list from oracle database and then submit it to another table in JSP. I... to the database and fetches an array of strings from a database table and then sends
inserting an path of an image in database - JDBC
inserting an path of an image in database  hello kindly help related... time its full path should be inserted in the database(MS Sql 2000).. I m able... be saved in the database...I have tried it but getting an error.. plz have a look
getting and storing dropdown list in database in jsp
getting and storing dropdown list in database in jsp  i have a drop down list to select book from database. i'm able to retrieve dropdown list from database. but unable to store the selected value in database table. please help
Inserting data from the HTML page to the database
program in which we are going to insert the values in the database table from... Inserting data from the HTML page to the database... the values will be passed to the server. (adsbygoogle
urgent help for inserting database in a project
urgent help for inserting database in a project   I need some urgent... and then the result at the end.I need to add simple database connectivity to it just a single table i guess which would have sno,username result and percentage
urgent help for inserting database in a project
urgent help for inserting database in a project   I need some urgent... and then the result at the end.I need to add simple database connectivity to it just a single table i guess which would have sno,username result and percentage
3 dropdown list from the database using JSP
3 dropdown list from the database using JSP  Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP
Insert Data in Table Using Stored Procedure
Insert Data in Table Using Stored Procedure        In this example we are inserting data into a table using stored procedure. Steps: 1.Create database
inserting into mysql database with uid to be primary key and autoincrement
; Here is the code of inserting values from jsp form to database. In the database table, set the uid as the primary key and auto-increment. Then, whenever...inserting into mysql database with uid to be primary key and autoincrement 
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 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
getting dropdown values using apache commons in servlet
getting dropdown values using apache commons in servlet  i want to get dropdown values in my program in order to merge the string to my file path so that the path will change dynamically according to user input.iam new to apache
How to add dropdown list in a row of a sort table applet?
How to add dropdown list in a row of a sort table applet?  How to add dropdown list in a row of a sort table applet
dispalying arraylist values in table form
dispalying arraylist values in table form  My result is in arraylist and i want to display it in table form using iterator tag
Insert Image into Database Using Servlet
image into database table using Servlet. This type of program is useful in social... into database. Please not the filed type used is blog. CREATE TABLE `pictures...Insert  Image into Database Using Servlet   
Insert  Image into Database Using Servlet
of inserting image into database table using Servlet. This type of program is useful... into database. Please not the filed type used is blog. CREATE TABLE... Insert  Image into Database Using Servlet   
Inserting Image in a database Table
Inserting Image in MySql Database Table... understand the concept of inserting a image in the database table, so go through... database which we are using.  After the connection establishment we will pass
Dynamically display values in dropdown box and then show the selected values as selected by the user which is already stored in the DB
Dynamically display values in dropdown box and then show the selected values.... so if I have 5 values in the dropdown this selected one is added as 6th values... selected values directly from the Database and not adding to it as an extra one
store values of drop down list box in database
store values of drop down list box in database  how to store values of drop down list box in oracle database in jsp?I have information inserting form where i have date of birth as drop down list box
show the database values graphical represantation
show the database values graphical represantation   show the database values graphical represantation and auto refresh for every 30 secand displaying in webpage
Printing Values of Resultset to Html Table
Printing Values of Resultset to Html Table  I have a resultset and I need to collect the resultset values into the arraylist into a table...; JSP Display values of ResultSet to HTML table: <%@page import="java.sql.

Ads