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



Home Answers Viewqa Ajax refreshing a jsp without flickering effect for every 5 seconds using ajax
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


suresh anugandula
refreshing a jsp without flickering effect for every 5 seconds using ajax
1 Answer(s)      3 years and 5 months ago
Posted in : 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.


Advertisement
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
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
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
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      
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
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
Draw graph using jsp without database connection
Draw graph using jsp without database connection  Draw graph using jsp code without database connection
Simple Ajax Example, Developing Simple Ajax application
application that sends the user name on the server without refreshing the page...Simple Ajax Example       Simple Ajax Example In this tutorial we are going to develop a very simple Ajax
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
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 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
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
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
how to call the parent page from child without refreshing the parent and my parent window uses the master page
how to call the parent page from child without refreshing the parent and my parent window uses the master page   how to call the parent page from child without refreshing the parent and my parent window uses the master page
how to call the parent page from child without refreshing the parent and my parent window uses the master page
how to call the parent page from child without refreshing the parent and my parent window uses the master page   how to call the parent page from child without refreshing the parent and my parent window uses the master page
how to call the parent page from child without refreshing the parent and my parent window uses the master page
how to call the parent page from child without refreshing the parent and my parent window uses the master page   how to call the parent page from child without refreshing the parent and my parent window uses the master page
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
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
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
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
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...; Create a jsp using the tag <s:div>.    
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
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
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
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...;</H3></BR> <table cellspacing=5 cellpadding=5
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
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
jsp and ajax
jsp and ajax  how to enable or disable textbox using radio buttons by using jsp and ajax
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
 

 

 

DMCA.com