September 22, 2008 at 6:38 PM
servlets code
package javacode;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
import java.util.ArrayList;
public class ComboboxList extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
Connection con = null;
String url = "jdbc:
mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String password="amar123";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from Combolist");
List ulist = new ArrayList();
List clist = new ArrayList();
while(rs.next()){
request.setAttribute("userid", rs.getString(2));
request.setAttribute("city", rs.getString(3));
pw.println("userid" + " "+"city"+"<br>");
pw.println(rs.getString(2) + " " + rs.getString(3) +"<br>");
ulist.add(rs.getString(2));
clist.add(rs.getString(3));
}
request.setAttribute("useridList", ulist);
request.setAttribute("cityList", clist);
}
catch (Exception e){
pw.println(e);
}
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/jsp/Combobox.jsp");
dispatcher.forward(request, response);
}
}
Related Tutorials/Questions & Answers:
dynamic drop down listdynamic drop down list I want to create 2
drop down list, where it takes value from database and the two
list are dependent..means if I select a particular value from one the other
list is developed accordingly..depending
Advertisements
Dependant & dynamic drop down listDependant &
dynamic drop down list I don't know this should be in this or AJAX forum.
I have one
dynamic drop down list from data base (working... on the values selected by user in first
drop down list.
How to achieve this ?
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 Dependant & dynamic drop down list - Follow upDependant &
dynamic drop down list - Follow up Thanks for your answer. As per your answer
This will select only ONE row (country) from first
drop down. In my case user can choose more than one row , which is then sent to next
Drop Down BoxDrop Down Box In a
Drop Down box I want to show the user All the Country In the World. And when he type A-z,then each of the type Show those country which start with those word. Like I For-India
dynamic drop down dynamic drop down I have created 2
drop downs in jsp.1 for department and other
for its related designation.that means if I select a department... into the designation
drop
down
(use jsp+javascript+servlet)
reply soon
1
drop down box - JSP-Servletdrop down box when i enter some letter in the input
box,the corresponding words of that particular letter must be displayed below as a
list from the data base in the same input
box as
drop down.
Thanks&Regards,
VijayaBabu.M
validation for drop down listvalidation for
drop down list Hi all
I have a form, it contain 12
drop down list. Each
drop down has 1 to 5 values,i need to validate this form. the following condition should be true.
1.you can choose only 3 times 5 value.
2
Dependent drop down list dependent
drop down list is used my code is successful but when i select class from first
drop down list all the data get lossed means the value entered in fields before
drop down list get blank.what can i do for this?
This is the code
Get values in drop down listGet values in
drop down list Pls provide me jsp code to get values in
drop down list from another table's field.
my project has customer... in
drop down box in front end..... pls provide me code.. thanx
Drop down list from databaseDrop down list from database Hi, Can I know how do we get the
drop down list from database? Eg: select country--select state--select district--so on.
1)country.jsp:
<%@page import="java.sql.*"%>
<html>
dependent drop down box - JSP-Servletdependent
drop down box haloo sir
Please give me the solution how to extract data from dependent
drop down box with page refresh, If possible please give some example for better understanding
Select functionality of drop down list - Struts have
Drop down list having element Test1,Test2,Test3,HIDE and one Text msg
box for entering Age,Now if user select "HIDE" from
drop-
down list the below text...(in struts application) in which if user select HIDE from the
drop down list Excel Cell Drop Down ListExcel Cell
Drop Down List
In this section, you will learn how to validate data entered in a cell and
provide a
drop down list of possible values to the user... in a excel sheet's
cell and also can provide
drop list of possible value
view data from database using drop down listview data from database using
drop down list hi i want to view the data from database by selecting a value in a
drop down list. for an example
drop down list have picture element.when click it select pictures from the database
Drop BoxDrop Box program draw 2d shapes in java
Drop BoxDrop Box program draw 2d shapes in java
Dynamic Dropdown Menu records from your database in a
drop down menu/
list box. You can apply it as
a navigator
list box. Good for saving your webpage areas or you have many links
you..._TO_REPLACE_5
<title>
Dynamic
Drop Down List</title>
</head>
<
How to create a dependent drop down list using [Apache POI]How to create a dependent
drop down list using [Apache POI] Here I.... In that two
drop down list are there. Want to create a
drop down list that depends..., and "rice, curd, milk" items will appear in the dependent
drop down list in cell
How to create a dependent drop down list using [Apache POI]How to create a dependent
drop down list using [Apache POI] Here I.... In that two
drop down list are there. Want to create a
drop down list that depends..., and "rice, curd, milk" items will appear in the dependent
drop down list in cell
drop downdrop down how can i add data from choice/dropdown component of java awt to myaql table
Drop DownDrop Down How to insert date into database using dropdown like facebook
Drop Down reload in IEDrop Down reload in IE Hi i was using two
drop down box..One for Displaying date followed by another for Dispalying Month..If i Select/Change Month from the 2nd
drop down then the 1st
drop down ( which is date) automatically
Login With Drop Down box and then login to the page.
I have a
drop down list box with Customs... a
drop down list consisting of Customs and Accounts. I have user accounts of both... by selecting the
drop down box. Suppose the Customs username is 1001 and Accounts
Drop down menuDrop down menu I have
drop down list of some 14 links which links to the table,If i click each link the table should display below the link and again if i click the link the table should not appear. please help me