Refresh code

Refresh code

View Answers

October 24, 2008 at 3:30 PM

Hi friend,


<%@ page language="java" import = "java.util.*;"%>
<%
List userList;
int nouser;
int i=1;
List cityList;
int nocity;
int j=1;
%>
<%
userList=(ArrayList)request.getAttribute("useridList");
nouser = userList.size();
%>

<%
cityList=(ArrayList)request.getAttribute("cityList");
nocity=cityList.size();
%>
<html>
<head>
<title>dynamic bombobox in servlet</title>
</head>
<body>
<br><br>
<center>
<table border="1" width="300px" bgcolor="bluelight" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<form method="GET" action="/examples/jsp/ComboboxList">
<font color="red"><h3 align="center">Dynamic Combobox List</font></h3>
<table border="1" width="300px" cellspacing="0" cellpadding="0">
<tr>
<td width="50%"><b>User Name:</b></td>
<td width="50%"><select name="userid" value="">
<option value="0">---Select Name---</option>
<%
Iterator userit= userList.iterator();
while(userit.hasNext()){
while(i<=nouser){%>
<option value="<%=i%>"><%=userit.next()%></option>
<%
i++;
}
}
%>
</select>
</td>
</tr>
<tr>
<td width="50%"><b>City:</b></td>
<td width="50%">
<select name="city" value="">
<option value="0">----Select city----</option>
<%
Iterator cityit= cityList.iterator();
while(cityit.hasNext()){
while(j<=nocity){%>
<option value="<%=j%>"><%=cityit.next()%></option>
<%
j++;
}
}
%>

</select>

</td>
</tr>

</table>

</form>
</td>
</tr>
</table>
</center>
</body>

</html>

October 24, 2008 at 3:31 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);
}
}

-------------------------------------


October 24, 2008 at 3:34 PM

Read for more information.

http://www.roseindia.net/servlets/


Thanks.









Related Tutorials/Questions & Answers:
Refresh code - Java Server Faces Questions
Refresh code  Hi All, In Drop Down Box i have 5 items if i select one item it is displaying item number beside that box.after...----   servlets code package javacode; import
UIBarButtonItem Refresh
, refresh button using code in iPhone application?? If yes then how?   ... the refresh button... i'm providing you the example of Navigation Refresh UIBarbuttonItem...] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh
Advertisements
Refresh JFrame
Refresh JFrame  How to refersh a JFrame and its componets
refresh jsp page - Ajax
refresh jsp page  Code for refresh a web page in jsp.  Hi friend, function refreshpage() { window.location.reload
Part refresh without a page refresh
Part refresh without a page refresh  hello, How do I submit a form or a part of a form without a page refresh?   hii,ADS_TO_REPLACE_1 Ajax can do this. You can do partial update and upon a successful AJAX
Table refresh with ajax - Ajax
Table refresh with ajax  I am using jsp/html in my code. Is it compulsory that i have to use a servlet to implement table refresh using ajax? Or jsp also would work? Rajatha
Servlet refresh page
refresh code into HTML page. Read more at http://www.roseindia.net/software...Servlet refresh page In this example we will show you how you can refresh your page from setting the refresh attribute from a servlet. response.setHeader
prevent browser refresh
prevent browser refresh   prevent browser from refresh in Javascript
refresh checkbox jframe
refresh checkbox jframe  How to refresh checkbox button in JFrame
Captcha Refresh - Jquery
Captcha Refresh - Jquery  I'm looking for an example to refresh the Captcha image in Jquery ..every time the page get refresh. Thanks.   $("#refresh").click(function() { $("#captcha").attr("src","captcha.php?r
ModuleNotFoundError: No module named 'refresh'
ModuleNotFoundError: No module named 'refresh'  Hi, My Python... 'refresh' How to remove the ModuleNotFoundError: No module named 'refresh... to install padas library. You can install refresh python with following command
how to refresh my GUI page
how to refresh my GUI page  how to refresh a GUI in java
Refresh the form - Struts
Refresh the form  Hi How Can i control the page that doesn't go to refresh when i am doing 1 or more action from same page and forward those action again to same page. how can i control the doesn't go to refresh in that page
servelt refresh page
servelt refresh page   write a program in servlet that display the cricket score.the page should automatically refresh on every 5 seconds.the score... should fall down.the page should not refresh after 5 overs is completed
refresh rate in ajax
refresh rate in ajax  my data is in table which is generated dynamically. i want to refresh that perticular table after some time using ajax and with jsp
Client side refresh
Client side refresh  What is client side refresh?   ... by all browsers. <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/servlet/MyServlet/"> This will refresh the page in the browser automatically and loads
Windows 7 refresh DNS
Windows 7 refresh DNS  Windows 7 refresh DNS How to refresh DNS... to refresh the DNS. go to the command prompt (dos prompt) and then issue the following command: ipconfig /flushdns Above command will refresh the DNS data
jsp dropdown refresh - JSP-Servlet
jsp dropdown refresh  Sir Thank u for your jsp code... but the probleam during data extraction when i select first drop down its refresh then 2nd drop down it also refresh. so i cannot get the selected data. Please kindly give
Table refresh with ajax - Ajax
Table refresh with ajax  Hi, I want to update my table which has... or if the database is updated, i want my table to be updated automatically. For this i think i need to use ajax where a particular area in the page can
refresh - JSP-Servlet
. Is there any other way to refresh that particular place instead of refreshing whole page
ModuleNotFoundError: No module named 'db_refresh'
ModuleNotFoundError: No module named 'db_refresh'  Hi, My Python... 'db_refresh' How to remove the ModuleNotFoundError: No module named 'db_refresh' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'db_refresh'
ModuleNotFoundError: No module named 'db_refresh'  Hi, My Python... 'db_refresh' How to remove the ModuleNotFoundError: No module named 'db_refresh' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'ecs-refresh'
ModuleNotFoundError: No module named 'ecs-refresh'  Hi, My Python... 'ecs-refresh' How to remove the ModuleNotFoundError: No module named 'ecs-refresh' error? Thanks   Hi, In your python environment
page refresh - JSP-Servlet
up window has to close and jsp page has to refresh. how can i solve
How to refresh Client only once by sending setHeader ("refresh" ,??? )
How to refresh Client only once by sending setHeader ("refresh" ,??? ) ... to be refreshed ?? I just want to refresh my client page only once....! Not periodically... / REFRESH ....! I want to reload Client side only once when some event occur and flag
Hoe to refresh a table row dynamically
Hoe to refresh a table row dynamically  Want to refresh a table data when a particular link is clicked. How can i do using ajax ?   Hello... will able to refresh a particular table row?ADS_TO_REPLACE_1 Please clarify
Maven Dependency play-auto-refresh >> 0.0.1
You should include the dependency code given in this page to add Maven Dependency of com.jamesward >> play-auto-refresh version0.0.1 in your project
Maven Dependency play-auto-refresh >> 0.0.3
You should include the dependency code given in this page to add Maven Dependency of com.jamesward >> play-auto-refresh version0.0.3 in your project
Maven Dependency play-auto-refresh >> 0.0.4
You should include the dependency code given in this page to add Maven Dependency of com.jamesward >> play-auto-refresh version0.0.4 in your project
Frame refresh problem - Swing AWT
Frame refresh problem  Whenever I close a child frame and reload it using the button on parent frame controls on the child frame load twice..., Try the following code: import java.awt.*; import javax.swing.*; import
Client Auto Refresh in Servlets
Client Auto Refresh in Servlets       This section illustrates you how client gets auto refresh. We are providing...("Refresh", "15") refreshes the servlet after every 15 seconds till
Click on Page Refresh - JSP-Servlet
facing a problem whenever i click on page refresh or f5 button, the value on form... is click". If u have more problem then give error page code. Thanks....... use the following code in your jsp page but aftr adding this you
cache refresh after 24 hours
cache refresh after 24 hours  I have developed an application which uses websphere application server 6.1 which needs to query the database(oracle) after every 24 hours periodically.But it is not getting executed properly because
Version of com.jamesward>play-auto-refresh dependency
List of Version of com.jamesward>play-auto-refresh dependency
ModuleNotFoundError: No module named 'odoo10-addon-delivery-auto-refresh'
ModuleNotFoundError: No module named 'odoo10-addon-delivery-auto-refresh' ...: ModuleNotFoundError: No module named 'odoo10-addon-delivery-auto-refresh' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-delivery-auto-refresh
ModuleNotFoundError: No module named 'odoo10-addon-delivery-auto-refresh'
ModuleNotFoundError: No module named 'odoo10-addon-delivery-auto-refresh' ...: ModuleNotFoundError: No module named 'odoo10-addon-delivery-auto-refresh' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-delivery-auto-refresh
ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh'
ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh' ...: ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh
ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh'
ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh' ...: ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh
ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh'
ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh' ...: ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh' How to remove the ModuleNotFoundError: No module named 'odoo11-addon-delivery-auto-refresh
ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh'
ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh' ...: ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh
ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh'
ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh' ...: ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh
ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh'
ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh' ...: ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh
ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh'
ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh' ...: ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh
ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh'
ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh' ...: ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh' How to remove the ModuleNotFoundError: No module named 'odoo12-addon-delivery-auto-refresh
ModuleNotFoundError: No module named 'os-refresh-config'
ModuleNotFoundError: No module named 'os-refresh-config'  Hi, My... named 'os-refresh-config' How to remove the ModuleNotFoundError: No module named 'os-refresh-config' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'refresh-my-ip'
ModuleNotFoundError: No module named 'refresh-my-ip'  Hi, My... 'refresh-my-ip' How to remove the ModuleNotFoundError: No module named 'refresh-my-ip' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'djangorestframework-jwt-refresh-token'
ModuleNotFoundError: No module named 'djangorestframework-jwt-refresh-token...: ModuleNotFoundError: No module named 'djangorestframework-jwt-refresh-token' How...-refresh-token' error? Thanks   Hi, In your python environment you
Refresh Button returns null point exception when clicked
Refresh Button returns null point exception when clicked  Dear all Please assist with the following: How to rectify a piece of code for the refresh button in java. When clicking the button it returns an error "null point
Refresh a Web Page Using In Servlet
.style1 { font-weight: bold; } Refresh a Web Page Using... example we develop an application to Refresh a web Page using Servlet. We...;) and refresh this web page and print the current Date and Time after 10 sec
title and keywords don't refresh in webpage - JSP-Servlet
title and keywords don't refresh in webpage  Hi, I changed the title and keywords on my main jsp page that is the entry point into my web... but it still doesn't work. Here is my new code for title and keywords. Linen

Ads