Home Answers Viewqa JSP-Servlet servlet program

 
 


Gopi
servlet program
1 Answer(s)      4 years and 9 months ago
Posted in : JSP-Servlet

View Answers

September 23, 2008 at 1:34 PM


Might be this code help u........

<html>

<head>
<script language="javascript">
var xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
function selctData(form)
{

var url = "/Data.java?r=" + new Date().getTime() ;
xmlObj.open("GET", url)

xmlObj.onreadystatechange = function()
{
if(xmlObj.readystate == 4 && xmlObj.status == 200)
{
var id = document.getElementById("second");
var result = xmlObj.responseText;
alert(result);
if(result != null){

var s = result.split(',');
var indx = 0;
for(indx=0; indx < s.length; indx++)
{
id.options[indx] = new Option(s[indx],s[indx]);
}
}
}
}
xmlObj.send(null);
}
</script>
</head>
<body>
<h1>On Select change data of another Select</h1>

<br>

<select id="second"></select>

</body>
</html>
----------------------------------
Data.java
==============

public class Data extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
int countryID=0;
String value = req.getParameter("country");
String time = req.getParameter("r");
System.out.println("R " +time);
System.out.println("vountry " + value);
String dbQuery1 = "Select country_ID FROM TB_countries WHERE country_name='" + value + "'";
String dbQuery2 = "";

PrintWriter out = res.getWriter();
String result="";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydatabase";, "root", "");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(dbQuery1);
while(rs.next()){
countryID = rs.getShort("country_ID");
System.out.println("countryid " + countryID);
}
dbQuery2 = "Select state_name FROM TB_states WHERE country_ID=" + countryID;
rs = stmt.executeQuery(dbQuery2);
while(rs.next()){
result = result + rs.getString("state_name") + ",";
}
}catch(Exception ex){

System.out.println(ex.getMessage());

}
out.write(result);
out.flush();
out.close();
}

}


Thanks
Rajanikant









Related Pages:
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program  Develop a servlet to count how many times the servelt is accessed
servlet program - JSP-Servlet
servlet program  Hi All, I just want to write a servlet program where in i want to retreive some data(some names) through a sql query from a sql... the servlet is executed .can you please send me the code? I hope my requirement
Program
Program  hey please help me ... How can write multiple choice question paper using radio button.After submit calculate marks and display our marks... can any body help for me.using servlet,html   Here is a jsp test
problem in servlet program
problem in servlet program  Dear Sir, I have a problem to insert the Blob type data like as video file, audio file in the database using Servlet and html code
servlet program for data store in oracle?
servlet program for data store in oracle?  how to store data in oracle through servlet program
how to write servlet program in eclipse?
how to write servlet program in eclipse?  how to write servlet program in eclipse
program code - JSP-Servlet
program code  what is the program code for LOGINFORM USING SERVLETS? RESPOND SOON
program code - JSP-Servlet
program code  what is the program code for LOGINFORM USING SERVLETS? RESPOND SOON
servlet
servlet  how to interact with a servlet from a swing program
jsp program - JSP-Servlet
jsp program  1.write a servlet program that finds out the given number is armstrong or not which has been submitted through a form? 2.create an application in jsp to redirect the request to any other page.  Hi Friend
jsp/servlet login program
jsp/servlet login program  <%@ page language="Java" import="java.sql.*" %> <HTML> <HEAD><TITLE>DataBase Search<...; </html> When I run the program, I get an error: The requested resource
program - JSP-Servlet
program  Example program on RequestDispatcher  Hi I am sending links, where u find about requestDispatcher method, how it work and. http://www.roseindia.net/javacertification/wcd-guide/machanism.shtml http
program of java - JSP-Servlet
program of java  hi friends... i hv faced a problem of jsp code.my problem is... i want to extract data from dropdown menu to the next jsp page..... and also i want to generate a serial no and with this serial no , i want
Program - JSP-Servlet
Program  Respected Sir, I urgently need a program in JSP and JDBC which will connect to MS-ACCESS for seeking the data of Employees whose fields are Emp_id and Emp_Name.. I need to Add,Delete,Modify and Query
servlet
servlet  i want a program for counting the no of times the servlet has been invoked
Program urgent - JSP-Servlet
Program urgent  Respected Sir/Madam, I am R.ragavendran.. Actually my code shows the following output: There is a combo box which contains all the ID's present in the database.. When I click or select any of the ID
Merging of java script with servlet program
Merging of java script with servlet program  how can we merge the java script with the any servlet program for making web application intractive.Is there any program you have.\please help me to sove out this problem
Program Urgent - JSP-Servlet
Program Urgent  Respected Sir/Madam, I am R.Ragavendran. I am in urgent need of the coding. My requirement is as follows: Beside Enter Employee ID text Box, There must be a small button. When user clicks this button, a small
servlet program problem - Java Beginners
servlet program problem   i used ur servlet example prg with xml file of helloworld program and i run dat program in tomcat, it shows only the files in my specified directory but when i clicked dat file name it just displaying
Servlet
Servlet  I want to know the steps to write a simple servlet program... .   Hello Friend, Follow these steps: Put servlet-api.jar inside the lib folder of apache tomcat. 1)create a servlet. import java.io.*; import
servlet
servlet  hi sir,this is ashok.i installed tomcat 6.0 and jdk-150.i checked the server it's working but when execute servlet program for the .class file it shows the errors javax.servlet is not exist.what can i do,please tell me
how to compile and run servlet program
how to compile and run servlet program   hello sir/mam i hve installed tomcat5.5 version and also have jdk1.6.0_14 installed but not able to run it or compile i m doing it first tyme pls help me in sorting out this problem. i hve
jsp/servlet login program - JSP-Servlet
jsp/servlet login program  hello sir, well i have a problem with some code(loginbean.jsp),which i actually got from ur site: i am trying to create a login program where a new user will be registered and his/her details stored
Servlet
-pattern> </servlet-mapping> </web-app> The Error is C:\Program... the same error <web-app> <servlet> <servlet-name>InsertServlet</servlet-name> <servlet-class>InsertServlet</servlet
Program Very Urgent.. - JSP-Servlet
Program Very Urgent..  Respected Sir/Madam, I am R.Ragavendran.. Thanks for your superb reply. I got the link you sent. But I find a simple problem which i hava tried my level best to solve.In the output, the text box
Image Program Urgent - JSP-Servlet
Image Program Urgent  Respected Sir/Madam, I am R.Ragavendran.. Actuaaly in the Image Selection coding which is produced below, I am getting the Emp ID in the Emp ID text box but not the exact Emp ID which I have selected
how to ruv servlet program in myeclipse blue edition?
how to ruv servlet program in myeclipse blue edition?  how to ruv servlet program in myeclipse blue edition?  Servlets are run in a web server. The servlet can be deployed to the web server as part of deploying your
how to connect j2me program with mysql using servlet?
how to connect j2me program with mysql using servlet?  my program...(a); } }; } servlet program is: import java.io.*; import java.util.... the response from the servlet page. DataInputStream
servlet - JSP-Servlet
servlet  1.how can i run servlet program without creating html and xml program on tomcat 5.0? 2.how to use weblogic for servlet
jsp program for bill generation - JSP-Servlet
jsp program for bill generation  hi, i just want to know how i write the jsp program for generation of bill for a gas connectivity systm  Hi Friend, Please provide some information like structure of bill. Thanks
how to run jdbc in jsp program - JSP-Servlet
how to run jdbc in jsp program  i want to use sql server 2005 in jsp program to store data.i know how to run simple program but this program i tried my best i am not able to do so.please give me the answer of this as soon
about a program
about a program  hi can anyone suggest program for this question.. it wil really be helpful.its based on *servlet programming* 1. First page should display a dropdown of mathematical operation (Add, Subtract, Multiply, Divide
jsp program
jsp program  for example assume four user u1,u2,u3,u4 having the passwords pwd1,pwd2,pwd3,pwd4 respectively.write a servlet for doing the following... this.store the user name password in the web.xml and acces them in the servlet by using
write a program in java to demonstrate the complete life cycle of servlet:
write a program in java to demonstrate the complete life cycle of servlet: ... for this program. my question is :Write a program in Java to demonstrate the complete life cycle of a Servlet
Java Program
Java Program  A Simple program of JSP to Display message, with steps to execute that program   Hi Friend, Follow these steps: 1)Go... the servlet api.jar file inside the lib folder. 4)Now create a jsp file
Program Arrow selection Most Urgent - JSP-Servlet
Program Arrow selection Most Urgent  Respected Sir/Madam, I am R.Ragavendran.. I got your coding which is highly appreciable.. As per my requiremennt,there are image buttons for each row in the database.. But i am
sample jsp-servlet-service-db program
sample jsp-servlet-service-db program  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http
Simple Program Very Urgent.. - JSP-Servlet
Simple Program Very Urgent..  Respected Sir/Madam, I am R.Ragavendran.. Thanks for your superb reply. I find a simple problem which i have tried my level best to solve.In the output, the text box is receiving some other value
without writing web.xml file we can write servlet program
without writing web.xml file we can write servlet program  Sir Morning... Sir I have one Question "without writing web.xml file we can write servlet program". if yes which way? if no why? but without use Annotation........ Plz
Servlets Program
Servlets Program  Hi, I have written the following servlet: [code] package com.nitish.servlets; import javax.servlet.*; import java.io.*; import... executed the program, it gave me error as follows
session realtime usage program simple jsp program or servlet ,which understands me importance of session
session realtime usage program simple jsp program or servlet ,which understands... like client state storage scope.,but jsp or servlet realtime simple session related program whether it may be loginpage or anything must simple understanding