hi i am trying to print data on jsp page in realtime scenario while another core engine is writing data into the file
this is the jsp script let code code
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page import="java.io.*"%> <%@ page import="java.util.*"%> <%@ page import="java.io.BufferedReader"%> <%@ page import="java.io.FileNotFoundException"%> <%@ page import="java.io.FileReader"%> <%@ page import="java.io.IOException"%> <%@ page import="java.util.ArrayList"%> <%@ page import="java.util.List"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Reading File from a Location</title> </head> <body> <form > <% List<String> list=new ArrayList<String>(); BufferedReader bufferedReader = null; try { String filename= "d:/test.txt"; //Construct the BufferedReader object bufferedReader = new BufferedReader(new FileReader(filename)); String line = null; while ((line = bufferedReader.readLine()) != null) { //Process the data, here we just print it out try { Thread.sleep(3000);//sleep for 1000 ms response.flushBuffer(); System.out.println(line); out.println("\n" +line+ "\n"); list.add(line); System.out.println(list); //out.println(list); list.clear(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } finally { //Close the BufferedReader try { if (bufferedReader != null) bufferedReader.close(); } catch (IOException ex) { ex.printStackTrace(); } } %> </form> </body> </html>
this d:/test.text basically is written from core engine after every stipulated time lets say every 3 secs
while the file is written , this test.txt, i am not able to show the data are written simultaneously in real time scenario, im able to show it after the file is wriiten..
please advise me, how to show the data on jsp in real time simultaneously when in the back hand , core engine is writing the data simultaneously