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



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


nena
how to get combo box value
1 Answer(s)      5 years and 2 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 "
 

 

 

DMCA.com