refreshing a jsp without flickering effect for every 5 seconds using ajax

refreshing a jsp without flickering effect for every 5 seconds using ajax

I want to refresh a jsp without flickering for every 5 seconds using ajax.This jsp is responsible to get the new records from the database and display the records in the form of a table. I don't know how to use ajax. Please send me one example for the same. Please help me. Please send your answer to.

View Answers

July 18, 2011 at 4:28 PM

1)ajax.jsp:

<%@page import="java.sql.*"%>
<META HTTP-EQUIV="Refresh" CONTENT="5">
<html>
<head>
<script type="text/javascript">
function showData(){ 
xmlHttp=GetXmlHttpObject()
    var url="getdata.jsp";
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged(){ 
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
     document.getElementById("tab").innerHTML=xmlHttp.responseText;   
    } 
}
function GetXmlHttpObject(){
var xmlHttp=null;
try{
  xmlHttp=new XMLHttpRequest();
 }
catch(e){
 try{
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch(e){
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
</script>
</head>
<body onload="showData();">
<table id="tab">
</table>
</body>
</html>

2)getdata.jsp:

<%@ page import="java.sql.*" %> 
<%
 String buffer="<table id='tab' border='1' >";  
 try{
  Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
 Statement stmt = con.createStatement();  
 ResultSet rs = stmt.executeQuery("Select * from employee");  
   while(rs.next()){
   buffer=buffer+"<tr><td>"+rs.getString("name")+"</td><td>"+rs.getString("address")+"</td><td>"+rs.getString("contactNo")+"</td><td>"+rs.getString("email")+"</td></tr>";  
   }  
 buffer=buffer+"</table>";  
 response.getWriter().println(buffer);
 System.out.println(buffer);
 }
 catch(Exception e){
System.out.println(e);
 }
 %>









Related Tutorials/Questions & Answers:
refreshing a jsp without flickering effect for every 5 seconds using ajax
refreshing a jsp without flickering effect for every 5 seconds using ajax  I want to refresh a jsp without flickering for every 5 seconds using ajax.This jsp is responsible to get the new records from the database and display
using jsp's....and ajax - Ajax
using jsp's....and ajax  Hi, i need code using ajax .....in a text box when i enter an alphabet i should get list of words starts with the alphabet given in the text box
Advertisements
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
Ajax Training Course
; Ajax to make a call to the server without refreshing a page. Modifying contents  on a web page without refreshing the whole page... Ajax Training Course      
Draw graph using jsp without database connection
Draw graph using jsp without database connection  Draw graph using jsp code without database connection
Ajax using jsp
Ajax using jsp  <%@ page import="java.io.*" %> <%@ page import="java.util.*" %> <%@ page import="java.sql.*" %> <%@ page import...); } %> Is there Any error...........In first Page I use ajax for displaying
ajax using jsp
ajax using jsp  <%@ page import="java.io.*" %> <%@ page import="java.util.*" %> <%@ page import="java.sql.*" %> <%@ page import="java.util.StringTokenizer" %> <%@ page import="java.lang.*" %> <
datagid with paging using jsp - Ajax
datagid with paging using jsp  datagrid with paging using ajax and jsp  Hi friend, For read more information : http://www.roseindia.net/jsp/data-grid.shtml Thanks
application using AJAX and JQuery and also use JSP
application using AJAX and JQuery and also use JSP   i need create an application using AJAX and JQuery and also use JSP
Refreshing JSP - JSP-Servlet
Refreshing JSP  Sir, I am retriving corresponding values to dropdown listbox2 dynamically from database when i select a single value within the same application in drop down list box 1 using javascript.location().My problem
retrive image from database using jsp without stream
retrive image from database using jsp without stream  How to retrive image from database using jsp without stream like (inputStream
Simple Ajax Example, Developing Simple Ajax application
application that sends the user name on the server without refreshing the page.ADS...Simple Ajax Example       Simple Ajax Example In this tutorial we are going to develop a very simple Ajax
Ajax with java(using Dojo) - JSP-Servlet
Ajax with java (using Dojo)  Hi, In In place Edit Box,when I click "save" button how can I save the data in server side i.e JSP or how can I call.... Is there a possibility for tutorial on Scriptaculous. us,for Java programmers
how to show effect (visual) on jsp page using value from database
how to show effect (visual) on jsp page using value from database  I am making a ticket booking system. I have a databse with a clumn "booking status" I am thinking to use a map of seats ( with pictures controllers as seats) What
how to build a colorful clock in JSP without using Flash.
how to build a colorful clock in JSP without using Flash.  I have to make a colorful clock using java programming or some API in a JSP page. Please send me a code for it as soon as possible
ajax code with jsp - Ajax
ajax code with jsp  hi , Sorry for insufficient data.i m making some correction on question. I have to perform some calculation on my jsp page. i want to do it automatically (using ajax in jsp). problem is - i hv two
Popup Window using Ajax In JSP
Popup Window using Ajax In JSP  ... Window application using Ajax in JSP. For this, we will create the following...;/FONT> </P></H3></BR> <table cellspacing=5
Create Listbox in JSP using AJAX control
Create Listbox in JSP using AJAX control  Hi everyone!!! I want... listbox to select single elemnt using AJAX control . But i don't know anything about AJAX. In that listbox,listbox items are dictly fetched from databases
access image from ajax store in mysql using jsp
access image from ajax store in mysql using jsp  access image from ajax store in mysql using jsp (code to access image captured by camera and store in mysql
How retreive data from database without using post method in jsp - JSP-Servlet
How retreive data from database without using post method in jsp  ... Ajax.We have provided you a link.In that example, with the use of Ajax, we take..., not on another page so use both the jsp pages. http://www.roseindia.net/jsp
jsp and ajax
jsp and ajax  how to enable or disable textbox using radio buttons by using jsp and ajax
jsp & ajax
jsp & ajax  how to enable or disable textbox using radio buttons by using jsp and ajax? plz help me.... i m new in jsp & ajax
How can I paginate a table which has shown in a div through Ajax in client side without using database
How can I paginate a table which has shown in a div through Ajax in client side without using database   The table is shown by calculation in a PHP script file so The data not store any where so please give me the way to paginate
how to get popup fro servelt to jsp by using ajax........
how to get popup fro servelt to jsp by using ajax........  how to get popup fro servelt to jsp by using ajax........ I went popup in jsp page when my form submit successfully.....through servlet can any buddy give r explian how
How to make a ajax application which take data from textarea and that page is not refreshing.
done this without using AJAX but I want to do this using AJAX...How to make a ajax application which take data from textarea and that page is not refreshing.  I am doing a application in that i am using Spring
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
displaying List of records from database in a jsp using ajax
displaying List of records from database in a jsp using ajax  Sir, I need to retrieve the records from the database for every 7 seconds and display...;%@page import="com.tbss.RtChannels"%><%@ taglib uri="http://java.sun.com/jsp
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I enter the letter A in the textbox it should show only those values which starts
ajax jsp - Ajax
ajax jsp  multiple combo with ajax using jsp?  Hi friend, I am sending you a link. This link will help you. Please visit for more information. http://www.roseindia.net/jsp/comboSelect.shtml Thanks
Ajac code with jsp - Ajax
to perform some calculation on my jsp page. i want to do it automatically that is possible using ajax. problem is - i hv two text box. 1st take... box automatically without refreshing page. If any body know this plz help me
how to generate reports from oracle database using jsp and ajax code
how to generate reports from oracle database using jsp and ajax code  Hai masters i am new to this Java world. my team leader ask me to generate sales report data from oracle database to jsp page please any one know how to do
basic login and registration web page using jsp and servlet without using bean .....
basic login and registration web page using jsp and servlet without using bean .....  Hello Folks please i m totally beginner so guys please help me with very simple solution..... thnx
Problem dispalying Country, City, State in JSP using Ajax in Struts Framework - JSP-Servlet
Problem dispalying Country, City, State in JSP using Ajax in Struts... showing data from database using ajax, jquery.. but it is not working.. It is because I am using dv to add rows dynamically. If I try working without using div
jsp - Ajax
jsp  I'm very new in using the jsp and ajax, i have some JSP pages and i need to add some ajax features in my jsp page, for the example i need.... How can I implement this and then add this to my jsp page? please
How to pass and catch HTML parameters to a Java program using REST services?(without using servlet/jsp)
How to pass and catch HTML parameters to a Java program using REST services?(without using servlet/jsp)  Hello, I am new to these technologies i.e.... and catch HTML parameters to a Java program using REST services?(without using
without using built-in functions
without using built-in functions  Hai sir... Please help me to solve this... Findout occurances of each string in every another string (built - in functions are not at all allowed) all, and, sand, falling wall and sand
Using Ajax
Using Ajax  Hi, How I can use Ajax in web programming? Tell me any example which using Ajax to call server side script? Thanks   Hi, Here are examples: PHP Ajax and Database First Ajax Example Getting Started
using ajax and jsp (struts) to login and remain on same page.
using ajax and jsp (struts) to login and remain on same page.  I am a fresher... I can forward my login page to success page using struts, but I.../struts/struts2/struts2ajax/ajax-login-form.shtml
jsp and ajax - JSP-Servlet
jsp and ajax  i had some problem i want to display the current system date and time in each and every page of my project just i want the time to be automatically updated for every second for that i want to make an ajax call
Ajax with jsp - Ajax
Ajax with jsp  multiple combo boxes with ajax in jsp?  Hi friend, I am sending you a link. I hope that, this link will help you. Please visit for more information. http://www.roseindia.net/jsp
Jsp Code:Refreshing Page - Java Beginners
Jsp Code:Refreshing Page  Dear Frnds, I have a problem where i need to refresh a page based on the button click. once a page is updated, it should refresh the data in another page. structure is given bellow... Empid EmpName
Div (Ajax Tag) tag Example
without refreshing the entire page. The div tag when used with Ajax refreshes the content of a particular section without refreshing the entire page. HTML...Div (Ajax Tag) tag Example      
JSP and AJAX very urgent - Ajax
JSP and AJAX very urgent  Hi Team, This is Ragavendran.R.. I have a very basic doubt in AJAX. While Using AJAX, of course, there will be tag involved in JSP page. But in my current project, I am using too many tags
show folder on server by clicking a row in table using jsp and ajax
show folder on server by clicking a row in table using jsp and ajax  Hi, i want a jsp page which has one dropdown and one textfield. when i click on serach button after selecting the dropdown and a value in textfield it should
show folder on server by clicking a row in table using jsp and ajax
show folder on server by clicking a row in table using jsp and ajax  Hi, i want a jsp page which has one dropdown and one textfield. when i click on serach button after selecting the dropdown and a value in textfield it should
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without

Ads