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



Home Answers Viewqa JSP-Servlet how to get combo box value

Have Programming Question? Ask it here!
 
 
 


nena
how to get combo box value
1 Answer(s)      4 years and 10 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

October 20, 2009 at 1:45 PM


Hi Friend,

Try the following code:

1) combo.jsp:
<%@page import="java.sql.*"%>
<form method="post" action="../Servlet">
<%
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/register";;
String query = "select * from student";
ResultSet rs = null;
Connection conn = null;
Statement stmt = null;
try {
Class.forName(driver);
conn=DriverManager.getConnection(url, "root", "root");

stmt = conn.createStatement();
rs = stmt.executeQuery(query);
%>
<select name="select">
<%
while(rs.next()){
%>
<option value="<%=rs.getInt("id")%>"> <%=rs.getString("name")%> </option>
<%
}
}
catch(Exception e){}
%>
</select>
<input type="submit" value="submit">
</form>

2)Servlet 'Servlet.java'

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

public class Servlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException{
PrintWriter out = response.getWriter();
String sel=request.getParameter("select");
out.println("You have selected "+sel);
}
}

3)Web.xml:
<servlet>
<servlet-name>Servlet</servlet-name>
<servlet-class>Servlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Servlet</servlet-name>
<url-pattern>/Servlet</url-pattern>
</servlet-mapping>

Thanks


Related Tutorials/Questions & Answers:
how to get combo box value - JSP-Servlet
how to get combo box value  i have created 1 servlet & 1 jsp page... to store that id in database. how to get that value???   Hi Friend... in combo box in jsp page: (small part of my code) "> now i want
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
Advertisements
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
How to pass the value of Selected Value of combo box into sql ??
How to pass the value of Selected Value of combo box into sql ??  My SQL Database Name is MHS, user=root, password=admin,table name is sub_comb... submit i want to display other field. how to get it?? plz help me
how can retrive value from combo box in servlet?
how can retrive value from combo box in servlet?  i have a jsp page with combobox. And i want to get value from combox to servlet
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  For example, In Employee.jsp form, When i click employee id value in combo box...... i already stored combo box values from database. pl
combo box value
combo box value   i want to populate one combo box value based on another combo box value using ajax   1)country.jsp: <%@page import...; xmlHttp.onreadystatechange = stateChange; xmlHttp.open("GET", url, true
combo box value
combo box value   i want to populate one combo box value based on another combo box value using ajax   1)country.jsp: <%@page...("GET", url, true); xmlHttp.send(null
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all... to get values from another form
How to get the values from the Combo Box - JSP-Servlet
How to get the values from the Combo Box   Sir, Actually i am getting the values in the combo box from table.I want what ever the value i select in combo box its corresponding records will display
How to retreive data by using combo box value - JSP-Servlet
How to retreive data by using combo box value  Hello friend , i am using only one form. U are using html form and jsp form. So get... I can print combo box values
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  Hi Friends... related value.... I am using only this page.. not get value from another page... For Example, in Student.jsp... when i click student id in combo box
How to retrieve data using combo box value in jsp? - JSP-Servlet
How to retrieve data using combo box value in jsp?  Hi freind, I already post this question. I need urgent help from u. pl response me.... All actions in the same page.......  Hi Friend, Please visit
How to retreive data by using combo box value - JSP-Servlet
How to retreive data by using combo box value  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use to get values from
Combo box value Error - WebSevices
Combo box value Error   if($_SERVER['REQUEST_METHOD'] == 'POST...']); } document.frmProposal.hdVisa.value = document.getElementById('cmbVisa').value; Error: The "cmbVisa" Value is Null,This error will displayed for these coding.So tell me
base the value of first combo box, how i display the second combox - JSP-Servlet
base the value of first combo box, how i display the second combox    i have a combo box for classes. my requirement is when i select the class, if class is 11 or 12 the second combo box of subject should be appear. please
Re: base the value of first combo box, how i display the second combox - JSP-Servlet
Re: base the value of first combo box, how i display the second combox  ... value of combo box should be sent. but when i clicked to submit button, it do...); } function hide(){ if (document.getElementById) { document.getElementById('combo
Re: base the value of first combo box, how i display the second combox - JSP-Servlet
Re: base the value of first combo box, how i display the second combox    thanks for your reply. i want to know suppose the second combo box appear only when i select the class 11th or 12th. please review. your answer
loading value into combo box by selecting value from other combo box - JSP-Servlet
loading value into combo box by selecting value from other combo box  ... is that as i select state from state_combo_box,then the next combo box is dynamically... box with constituency corresponding to district..... all three combo box
how to create a combo box in html
how to create a combo box in html  <tr> <td>Number<span class=mandatory>*</span></td> <td> <select name="number" id="course" style="width:158px;"> <option value="none">----Select
How to retrieve data from database by using combo box value in jsp? - JSP-Servlet
How to retrieve data from database by using combo box value in jsp?  ...="+emp_value xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url...; } function showEmp(emp_value) { if(document.getElementById("emp_id").value
How to create Combo Box in SWT
How to create Combo Box in SWT       This section illustrates you how to create a combo box... an action on the second combo box. The items tea , coffee and cold drink
Store combo box value - Development process
Store combo box value  Hi , this is my code. Here wen i click submit button combo values are stored like 1,2,3... but i want to store value . plz... message the data entered in first field should not be erased .i think the page get
combo box - JSP-Servlet
combo box  how to get a combo box in jsp page which allows editing as well as list box
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking the value of combo box . I am not getting it plz help me out .   hi
combo box
combo box  Hi, [_|] dropdown box... a screen like this using jsp-servlet(or DAO,DTO),in that drop down box i should get usernames from the database & upon selection of particular user i should get
populate Combo Box dynamically
populate Combo Box dynamically  Hi, How to populate the Combo Box dynamically using Flex with Jsp's
Dojo Combo Box
Dojo Combo Box          In this section, you will learn what is combo box and how to create a combo box in dojo. For creating the Combo box  you need "
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file."
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file."  Hi, How to get data from MYSQL Database tables on giving a "text" in a text-box in a JSP file. Ex:dept table; if we give dept_no in a text-box in JSP
Code to store sub combo box value - Development process
Code to store sub combo box value  Hi Deepak, In the following code i want to store subcombo box value instead of number. Already "Dkn/Tmz" ,"kungumam... etc are storing but i want to store "Circulation,marketing
my table should be reseted to new value upon the selection of the combo box..
my table should be reseted to new value upon the selection of the combo box..  import java.awt.Container; import java.awt.FlowLayout; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.sql.Connection
Loading combo box from oracle
Loading combo box from oracle  how can i load values into a combobox from oracle database when a value is selected in another combo box
how to get radio value
how to get radio value    how to retrive the option value and insert the next table pls give example
date in combo box
date in combo box  strong texthello, how can i desplay the current year and next year in combo box???!!! it must be uppdate atumaticaly every year>>>
Combo Box operation in Java Swing
the Combo Box component, you will learn how to add items to the combo box... holds the integer value for the position number of he of the item in combo box... Combo Box operation in Java Swing   
How to create textbox on combo value selection using javacsript in jsp?
How to create textbox on combo value selection using javacsript in jsp?  dynamically create textbox on combo value selection. when select multiple values then create multiple textboxes
assigning arraylist to combo box
assigning arraylist to combo box  Hi I am busy coding the Airline Reservation program, i have an arraylist of locations which i want to assing to the combo box. please help
Problem With Combo Box Editable Property
Problem With Combo Box Editable Property  Hi I am new To Flex i had set Combo Box Editable Property as true. But I didn't get the property filtering in the combo box like when you enter text "S" in the combo box then the names
combo box connection
combo box connection  how to provide connection between three combo boxes,if my 1st combo box is course and 2nd combo box is semester and 3rd combo box is my subjects.what's the coding to provide the connection between this three
populating the combo box - Struts
populating the combo box  Hi I am having problem populating the combo box with a table in MS SQL Server 2005 Management Studio Express. Belo...; get_mainSector.setInt(1, 0); // get_mainSector.setString(2, null
java combo box
java combo box  how to display messagedialogbox when the combobox is null, Thanks in advance
how to get the checkbox value in jsp
how to get the checkbox value in jsp  how to get the checkbox value in jsp?   JSP CheckBox Example - how to get the checkbox value in jsp
Combo Box - Struts
Combo Box  I hava acombo box cnnected to my database via html collections. When selecting an option, i want to display specific parts (sectons) on my web page....am trying to use logic:present and logic:empty but its not working
Helps with combo box and frame
Helps with combo box and frame  Hi i have a combobox and when i click... on the second window and click confirm i would have the information on the combo box. i don't really know how to doing it.   Sorry i forget to put my code i
JavaScript Dynamic Combo Box
: On selecting the value from the first combo, related values will get displayed...JavaScript Dynamic Combo Box Here we are going to create dynamic combo box... in respective arrays. As the user selects a country from the first combo box, the cities
To get the value of more than one text box in an HTML page to a jsp page - JSP-Interview Questions
To get the value of more than one text box in an HTML page to a jsp page  An html file has a text box as To get the value of this text box in a JSP... file has a text box as To get the value of this text box in a JSP file
How to get enum value in Java
How to get enum value in Java  Hi all, i am looking for a solution to get an enum value from index in Java. Please suggest. Thanks
 

 

 

DMCA.com