Impact of Media on Youth

Topics: Ajax, HTML, XMLHttpRequest Pages: 10 (2030 words) Published: April 27, 2013
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP and Servlet using AJAX</title> <script type="text/javascript">
function getXMLObject() //XML OBJECT
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP") // For Old Microsoft Browsers }
catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP") // For Microsoft IE 6.0+ }
catch (e2) {
xmlHttp = false // No Browser accepts the XMLHTTP Object then false }
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') { xmlHttp = new XMLHttpRequest(); //For Mozilla, Opera Browsers }
return xmlHttp; // Mandatory Statement returning the ajax object created }

var xmlhttp = new getXMLObject();//xmlhttp holds the ajax object

function ajaxFunction() {
var getdate = new Date(); //Used to prevent caching during ajax call if(xmlhttp) {"GET","gettime?" + getdate.getTime(),true); //gettime will be the servlet name xmlhttp.onreadystatechange = handleServerResponse;
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttp.send(null);

function handleServerResponse() {
if (xmlhttp.readyState == 4) {
if(xmlhttp.status == 200) {
document.myForm.time.value=xmlhttp.responseText; //Update the HTML Form element }
else {
alert("Error during AJAX call. Please try again");
<form action="" name="myForm">
Server Time:<input type="text" name="time" />
<br />
<input type="button" onClick="javascript:ajaxFunction();" value="Click to display Server Time on Textbox"/> <br />


<%@page contentType="text/html"pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""> <html>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Domestic Flights</title>
<center><h1>Travel Easy</h1>
<h3>-A Smarter way to travel</h3>
<%@page language="java"%>
<%@page import="java.sql.*"%>
<%@page import=
",java.text.ParseException"%> <%
String type=request.getParameter("group1");
String from=request.getParameter("txt_from");
String to=request.getParameter("txt_to");
String depart=request.getParameter("txt_depart");
String ret=request.getParameter("txt_return");
String no=request.getParameter("txt_no");
String airline=request.getparameter("airline");
String sTable=type;
String sSql="SELECT*FROM" sTable "WHERE From="from" and To="to" and DepartDate="depart" and SeatCapacity>="no""; String sDBQ="d:/" airline".mdb";
String database="jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ="sDBQ";DriverID=22;READONLY=true"; Connection cn=null;
Statement st=null;
ResultSet rs=null;
ResultSetMetaData rsmd=rs.getMetaData();
String s1,s2,s3,s4,s5,s6,s7,s8;
int i=1;
String flight_no[]=new String[100];
//out.println("form name='Air1line' action="method='post'><b>"i"." rs.getString(1) "</b><br><br>"); out.println("<h3><b>"airline" Flights</b></h3><br>"); out.println("<table cellspacing=20 cellpadding=15>");...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Impact of Media on Modern Youth Essay
  • Essay on impact of media on youth
  • The Media Impact on Youth Violence Essay
  • The Impact of Media On Youth Violence Essay
  • media impact Essay
  • Impact of the Internet and Media for Modern Youth Essay
  • Impact of Media Essay
  • Essay on Impact of Media on Purchase Decision of Youth

Become a StudyMode Member

Sign Up - It's Free