September 9, 2008 at 6:26 PM
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);
}
}
----------------------------------------------------------
Read for more information with example at
http://www.roseindia.net/servlets/Thanks
Amardeep
Related Tutorials/Questions & Answers:
Advertisements
Loading combo box from oracleLoading combo box from oracle how can i load values into a combobox from oracle database when a value is selected in another
combo box JavaScript Dynamic Combo BoxJavaScript
Dynamic Combo Box
Here we are going to create
dynamic combo box. For this, we have created two
combo boxes where combo1 represents countries... in respective arrays. As the user
selects a country from the first
combo box, the cities
Acees data from database using combo box - JSP-ServletAcees data from database
using combo box please let me how i access the data from database when i select
combo box combo2 having values Arts, Commerce, Science. this
combo box will appear when first
combo box class_name having
combo box - JSP-Servletcombo box I am
using a JSP form in which a combobox is given and I want to populate data in it from database and on the basis of yhe selected item I want to display related data in a textbox Hi Friend,
Create
how to get combo box value - JSP-Servlethow to get
combo box value i have created 1
servlet & 1 jsp page. in
servlet page i have fired query & fetched name & its id & that i have shown in
combo box in jsp page:
(small part of my code)
">
now i want
Populate a combo box using data from a databasePopulate a
combo box using data from a database Hi Guys, In need... to the client
using ajax, and then populate the
combo box, I must'nt reload...
combo box which will then load the
next
combo box values,
now i know how
dynamic drop down list box - Java Beginnersdynamic drop down
list box hi all ,
I want to dynamically populate a drop down
box from an sql query in a
servlet program,
using only html...
servlet comes under server side code.
if not
using servlet store the all data
List Box - JSP-ServletList Box sir
i am developing webb application.am
using drop down
list box.on selecting one value in
list box,i will retrieve values from database and store into another
list box in same page
using javascript :location.my
combo box a screen like this
using jsp-
servlet(or DAO,DTO),in that drop down
box i should get...
combo box Hi,
[_|] dropdown
box...] | |
| LEFT
LIST | | RIGHT
LIST Retrieving data from data base using jsp combo boxRetrieving data from data base
using jsp
combo box Hi guys please help me , i have on GUI page int that Server type(like apache,jboss,weblogic) one
combo box is there and another filed is version of the server(like 1.0,2.0) like
Javascript List Box - JSP-Servlet itself.my problem is in
list box the semester which i selected is not showing in
list box as selected.when i select,the page refreshes but i get the result what i expected.i need to show in
list box as semester is selected but it doesnt
How to get the values from the Combo Box - JSP-Servlet,
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 in their respective text
box.
e.g suppose i select ram values from the
combo box and its
retrieving from oracle database using jsp combo boxretrieving from oracle database
using jsp
combo box hi this is my code in this once i select the server type and version of the server the process... database please help on this i need code
using servlets please help me .
<
scroll bars to list box - JSP-Servletscroll bars to
list box Can I add scroll bars to a
list box in struts? Hi friend,
Scroll the
list box in struts
Two attribute set "multiple" "size".
Select Tag Example
Select Tag
date in combo boxdate 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>>>
assigning arraylist to combo boxassigning 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
Combo Box - StrutsCombo 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
populating the combo box - Strutspopulating the
combo box Hi
I am having problem populating the
combo box with a table in MS SQL Server 2005 Management Studio Express.
Belo...) {
ArrayList
list = new ArrayList();
try {
connectToDb();
// String sec = null
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="java.sql.*"%>
<html>
<head>
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="java.sql.*"%>
<html>
<head>
<script language
Helps with combo box and frameHelps 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...
combo;
JTextField txtBox;
private String PersonViewing;
private String
combo box connectioncombo 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
Problem With Combo Box Editable PropertyProblem 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
Loading JApplet into Servlet - AppletLoading JApplet into Servlet Hi,
I am in need of
loading..., Mozilla 1.7...
Could you let me know the procedure to load applet into
servlet classs.
As of now, we are
using tag to load JApplet, which is working only
Dojo Combo BoxDojo
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 "
Disable of Combo - JSP-Servlet/JSF/Struts1/Struts2 etc..
For more information on
combo box visit to :
http... am giving grading facility to the user. Once user selected his grade in
combo , the
combo should be disabled auotmatically. It should not get enabled at any
java combo boxjava
combo box how to display messagedialogbox when the combobox is null,
Thanks in advance
combo box code problemcombo box code problem in this my problem related to :
when i select state MP then i wil open the its corresponding city but in database it only stores the option value no like MP at option value 10 then it will stores the 10
Bulk insert and dynamic schema loadingBulk insert and
dynamic schema loading Hi All,
I am new to H2 database and java. I have started working on these from past 1 month. I needs some assistance regarding H2 database.
Overview of my work :
I get the query from