code for jsp
View Answers
September 17, 2008 at 11:47 AM
Hello Friend
I send the code you have to modify it by providin your driverclass, username and password
Data.java (ServletClass)
-------------------------
package com.rajanikant;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Data extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
System.out.println("inserv");
String value = req.getParameter("country");
PrintWriter out = res.getWriter();
String result="";
try{
Class.forName("driverclass");
Connection con = DriverManager.getConnection("url", "usernmae", "password");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select country from YourTableName Where country='" + value +"'");
while(rs.next()){
result = result + rs.getString("countryName") + ",";
}
}catch(Exception ex){
}
//result = "rajani,rani,sama,";
out.write(result);
}
}
selectDemo.jsp
-----------------
<html>
<head>
<script language="javascript">
var xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
function getData(source, div){
var element = document.getElementById(div);
if(xmlObj){
xmlObj.open("GET", source);
xmlObj.onreadystatechange = function(){
if(xmlObj.readyState == 4 && xmlObj.status == 200){
alert(xmlObj.responseText);
element.innerHTML = xmlObj.responseText;
}
}
}
xmlObj.send(null);
}
function getDetail(source,div){
getData(source,div);
}
</script>
</head>
<body>
<h1> An Ajax Demo</h1>
<form>
<input type="button" value="From Servlet " onclick="getData('../../Data?r='+ new Date().getTime(),'show')">
</form>
<div id="show">
<p>Data fetched Here</p>
</div>
</body>
</html>
Thanks
Rajanikant
September 17, 2008 at 12:35 PM
Hi friend
sorry the jsp page for another program
look this file
<html>
<head>
<script language="javascript">
var xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
function selctData(form)
{
var source = (form.first.options[form.first.selectedIndex].text)
var url = "../Data?country="+source;
xmlObj.open("GET", url)
alert("3");
xmlObj.onreadystatechange = function()
{
if(xmlObj.readystate == 4 && xmlObj.status == 200)
{
var id = document.getElementById("second");
var result = xmlObj.responseText;
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>
<form>
<select id="first" onchange="selctData(this.form)">
<option value="">Select One </option>
<option>1</option>
<option>2</option>
</select>
<select id="second"></select>
</form>
</body>
</html>
Thanks
Rajanikant
Ads
Related Tutorials/Questions & Answers:
jsp code
jsp code what are the
jsp code for view page in online journal
JSP CODE
JSP CODE what is the
code for downloading images from database using
JSP?
Please visit the following link:
http://www.roseindia.net/
jsp/downloadimage.shtml
Advertisements
jsp code
jsp code hi i am Ruchi can anybody plz tell me the
jsp code... visit the following links:
http://www.roseindia.net/
jsp/user-search.shtml
http://www.roseindia.net/servlets/search.shtml
www.roseindia.net/
jsp/searchbook.shtml
jsp code
jsp code i want health management system project
code using jsp.its urgent
JSP CODE
JSP CODE Please help me as soon as possible.Its Urgent. I am working on my college ALUMNI PORTAL. I want to have a ADD FRIEND option in a user's profile. Please send me
code
jsp code
jsp code i want to
jsp code which are working as,i have three drop down menu 1st menu for class second menu for subject and third menu as chapter... according to selectde menu,,,,please send me such type
code,,,,plz help me
jsp code
jsp code how to display date in drop down list by
jsp thus the date start from current date and for next year it has to check leap year function to february then it display 30 for some months else 31 for other months
JSP code
JSP code I get an error when i execute the following
code :
<... = con.createStatement();
st.executeQuery(query);
%>
<
jsp:forward page="address.jsp"></
jsp:forward>
HTTP Status 500 -
type Exception report
message
code in jsp
code in jsp hi..
I had started a project on college admission system in which two operators has been introduced one is admin who can view all... want a
code to sort a list of students on the basis of there 12% marks and AIEEE
JSP code for forget password
JSP code for forget password I need forget password
JSP code..
example http://www.roseindia.net/users/forgotpassword.html
tree using jsp code
tree using
jsp code i want to draw a tree structure of a family hierarchy using
jsp code
JSP code problem - JSP-Servlet
JSP code problem HI..
I have a DB2 stored procedure wich return a result set.
I have made a report basing on this procedure using Crystal Reports.
How to pass parameters to this procedure with java
code in a
JSP page
need JSP Code.
need
JSP Code. **Hi I need
JSP code for selling Products which are in Database.
Please can any one help for this.URGENT...
Thank You..!
Abhijeet
JSP code for registration form
JSP code for registration form Haiiii
can u please tell me how to encrypt password field in registration form and to compare both password and confirm password fields using
jsp
JSP loggin code
JSP loggin code HI,
Please assist me with a
JSP code for logon,there should be the Remember me option for both username and password and Remember username for the username.
Thank you
Need a JSP CODE
Need a
JSP CODE *Hi I need
JSP source
code for selling products which are in database.. please can any one help me ..URGENT*
Thank You
source code in jsp
source
code in jsp how to insert multiple images in
jsp page of product catalog
jsp code plz
jsp code plz write
jsp code which takes student roll number as input...;Please visit the following links:
http://www.roseindia.net/
jsp/user-search.shtml
http://www.roseindia.net/
jsp/popup-window-using-ajax-in-jsp.shtml
The above links
forgot password code in jsp
forgot password
code in jsp forgot password
code in
jsp
Please visit the following link:
http://www.roseindia.net/jsf/richfaces
Regarding JSP code
Regarding
JSP code hello sir tell me the way to navigate different... interfaces in
JSP code I am using Oracle 10g database .Exactly problem with me is that i cant be able to write the
code for navigate different users from same login page
Jsp code for disabling record.
Jsp code for disabling record. I want a
Jsp and servlet
code for the mentioned scenario.
Q. A cross sign appears in front of each record, click to disable the record.System marks the record as disabled.The record
code - JSP-Servlet
code hi sir
my question is i have created a html ang
jsp code....
how to write the
code to accept an existing id and password. Hi Friend,
Try the following
code:
1)login.html:
Login
part of AES code in JSP
part of AES
code in JSP org.apache.jasper.JasperException: Unable to compile class for
JSP
An error occurred at line: 19 in the
jsp file...-tomcat-5.5.17_base\work\Catalina\localhost\yep.jsp\org\apache\
jsp\index_jsp.java:142
javascript Code - JSP-Servlet
javascript Code how to count controls in form and find no of contriols in html or
jsp page.for example one table is there with 10 rows,each row consists of 3 fields as 2 text box and one drop down box
Need a jsp code
Need a
jsp code I need a
jsp code in which when i select a value.....please help me for this.
The given
code retrieves the employee name...)For the above
code, we have created following table:
CREATE TABLE `employee
source code in jsp
source
code in jsp sir...i need the
code for inserting images into the product catalog page and
code to display it to the customers when they login to site..pls help me