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



Home Answers Viewqa JSP-Servlet inserting dropdown values into database table

Have Programming Question? Ask it here!
 
 
 


aswinks
inserting dropdown values into database table
4 Answer(s)      2 years and 3 months ago
Posted in : JSP-Servlet


hi i want to insert dropdown values into a database table by using jsp.


Advertisement
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... insert values in the MySQL database table. We know that tables store data in rows
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   ... to the MySQL database table.  Flow of the process : This program helps the user to insert an image in the MySQL database table. To insert
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
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
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
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 Data In Database table using Statement
Inserting Data In Database table using Statement... a values into the table so we need to write a query for inserting the values... to insert the data in the database from our java program in the table stored
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 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
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 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
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 suppose class a the corresponding section dropdown list should retrieve the section
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...,uniqueid,userfield,cdrcost) values ('" + calldate + "','" + clid + "','" + src
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 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
Dropdown code to retrieve result from oracle database
that will retrieve 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
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
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
disallow NULL values in a table.
disallow NULL values in a table.  How do I disallow NULL values in a table
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
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
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
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
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
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 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
Insert Data in Table Using Stored Procedure
into a table using stored procedure. Steps: 1.Create database: To create... mysql> use employee; Database changed 3.Create the table... Insert Data in Table Using Stored Procedure   
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. The values which we have entered
How to change the dropdown values based on other dropdown in itext pdf or in any other?
How to change the dropdown values based on other dropdown in itext pdf or in any other?  How to change the drop down values based on another drop down? For eg: If we select one county, that related states only come, if we select
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
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
dropdown
dropdown  I have a dropdown having 2 options-"Open"& "closed".When i select "open" option the related rows of data are retrieved from database and same with the other option.My database is Mysql and coding in PHP
Insert  Image into Database Using Servlet
of inserting image into database table using Servlet. This type of program is useful...: Here is the table structure used to store the image into database. Please... Insert  Image into Database Using Servlet   
Insert Image into Database Using Servlet
image into database table using Servlet. This type of program is useful in social... is the table structure used to store the image into database. Please...Insert  Image into Database Using Servlet   
Records are not inserting in to main table while running the mysql stored procedure.
Records are not inserting in to main table while running the mysql stored... that procedure records are not inserted into main table from temp table.But im getting msg... me with this issue. My Code: BEGIN select concat('Inserting into SD
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
Populate dropdown menu from database using jsp and servlet
Populate dropdown menu from database using jsp and servlet  please i need code to populate dropdown menu from mysql database using jsp and servlet. thanks
Advertisements
 

 

 

DMCA.com