Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Ajax ajax display
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


lavanya
ajax display
1 Answer(s)      6 years and 2 months ago
Posted in : Ajax



Advertisement
View Answers

October 25, 2008 at 1:04 PM


Hi friend,


Code to solve the problem :

"mainpage.jsp"

<html>
<head>

<title>Ajax Example</title>

<script language="Javascript">

function postRequest(strURL) {

var xmlHttp;

if (window.XMLHttpRequest) { // Mozilla, Safari, ...

var xmlHttp = new XMLHttpRequest();

} else if (window.ActiveXObject) { // IE

var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

}

xmlHttp.open('GET', strURL, true);

xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

xmlHttp.onreadystatechange = function() {

if (xmlHttp.readyState == 4) {

updatepage(xmlHttp.responseText);

}

}

xmlHttp.send(strURL);

}


function updatepage(str){

document.getElementById("result").innerHTML =

"<font color='red' size='5'>" + str + "</font>";;

}

function showCurrentTime(){

var rnd = Math.random();

var url="showTime";

postRequest(url);

}

</script>

</head>

<body>

<h1 align="center"><font color="#000080">Ajax Example</font></h1>

<p><font color="#000080">&nbsp;This very simple Ajax Example retrieves the

current date and time from server and shows on the form. To view the current

date and time click on the following button.</font></p>

<form name="f1">

<p align="center"><font color="#000080">&nbsp;<input value=" Show Time "

type="button" onclick='JavaScript:showCurrentTime()' name="showdate"></font></p>

<div id="result" align="center"></div>

</form>

<div id=result></div>

</body>

</html>

"MyServletAjax.java"

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

public class MyServletAjax extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html");
Date date = new Date();
PrintWriter pw = response.getWriter();
pw.println(date);

}
}

"web.xml"

<servlet>
<servlet-name>myservletajax</servlet-name>
<servlet-class>MyServletAjax</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myservletajax</servlet-name>
<url-pattern>/myServletAjax</url-pattern>
</servlet-mapping>


For read more information on Ajax:

http://www.roseindia.net/ajax/

Thanks






Related Tutorials/Questions & Answers:
ajax display - Ajax
ajax display  I send request from ajax page to servlet... i got response from servlet to ajax as a string.. i want to display that string line..., Code to solve the problem : "mainpage.jsp" Ajax
To display suggestions in a text box - Ajax
of Keyword to process page Using Ajax. 4)After getting the response you display... AJAX!"); return; } var url="gethint.jsp"; url=url+"?q="+str; url=url...To display suggestions in a text box  Hi All, I have a requirement
Advertisements
how to display the image in center - Ajax
how to display the image in center  i want to dispaly the image as center of the screen using javascript..while i am clicking the button ..any one give me the code for this one
filter and display html table data using ajax - Ajax
filter and display html table data using ajax  Hi i am stuck up... calling the ajax function called retrieveURL.from here goes to DisplayCategory.jsp i want to display the data retrieved from the session in a 2d array
Ajax
Ajax  send the example to fetch the data from the server by using ajax in java. for ex:-if there are states which is used to display in frontend we use ajax. send it to me
ajax
ajax  HI, In my application using ajax if i type a managername in the textbox it should display all the employees under the that manager... on search button it should display the employee details from database pls help
Ajax
Ajax  How to learn AJAX
ajax
ajax  please describe the ajax
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me   displaying List of records from database in a jsp using ajax, onclick it should display the results
Ajax
Ajax  Hi, What is Ajax? What is the use of Ajax? Thanks   Hi, Ajax is set of technologies used to develop dynamic web applications. In Ajax following technologies is used: a) JavaScript b) XML c) HTTP d) CSS Learn
Ajax
Ajax  how to impliment ajax in registration table using jsp-servlet
AJAX - Ajax
AJAX  What is AJAX?how we will use it in java?what is the use of AJAX?give me example?   hi friend, Ajax plays a major role... characteristics have made it popular among the users to develop their site using Ajax
display
display  please tell me how to display the content from database.. if we click on any image using servlets/jsp...please
Ajax
Ajax  how to include ajax in jsp page?   Hi, Please read Ajax First Example - Print Date and Time example. Instead of using PHP you can write your code in JSP. Thanks
ajax
ajax  how to connect ajax with mysql without using php,asp or any other scripting language. please answer soon
Ajax - Ajax
Ajax  What is Ajax ? How one can use ajax with Java
Ajax
in a tabular form. Same for >33kv We can use ajax where instead of a link a radio button can fetch the data and can populate a table.If ajax can be used
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  I am facing following problem, I am using ajax to get... part. Here am using tag to display the output.Whenever user clicks on the link...("display").innerHTML=xmlHttp.responseText
Ajax
options. I want to do it using ajax. My table is CREATE TABLE HT<em>
AJAX
ajax. My table is CREATE TABLE HTNEWMETER ( ID NUMBER (10) NOT NULL, METERNO
AJAX - Ajax
AJAX  what is Ajax?WHAT IS THE USAGE OF IT?WHERE WE HAVE TO USE IT? GIVE ME EXPLANATION WITH EXAMPLE?  Hi friend, Ajax : Asynchronous JavaScript and XML or Ajax for short is new web development technique used
how to display jsp page containing mysql query in particular division using ajax ?my code is below bt i cundt get it properly
how to display jsp page containing mysql query in particular division using ajax ?my code is below bt i cundt get it properly   index.html <... request; // The variable that makes Ajax possible! try{ // Opera 8.0
ajax - Ajax
ajax  Hi all, I want ajax validation in struts1.0 , I tried from many days but, i cound't find solution.. I am attaching my code here. struts... ("Your browser does not support Ajax HTTP"); return; } var s
ajax - Ajax
ajax  Dear Roseindia, I want small application using ajax validation in struts1 login. I tried from many days but, i coudn't get solution..Do some favour me..it's urgent. Thanqs for advance.   Hi
Ajax - Ajax
that : form1.html where all Ajax code is written : function showHint...){ alert ("Your browser does not support AJAX!"); return
ajax - Ajax
ajax  how getting corresponding values from database when we select one option in selection box the result display on either a select box or text box
AJAX - Ajax
("Your browser does not support AJAX!"); return; } var url="http://localhost
 

 

 

DMCA.com