ok. i replaced my bottom.jsp with ur bottom.jsp
problem:
1) page is flickering.
2) hello is not replaced by the date.
Main Topics
Browse All Topicsi am trying to learn page refresh at regular intervals(say 5 sec).
but i am not getting it working.
though the page is refreshing but the problem of FLICKERING is remaing.
my status bar is showing that flickering... thats not good.
here is my code i which tried.
refreshTest.jsp
==================
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<FRAMESET ROWS="50,50">
<FRAME name="main" src="top.jsp" id="bottom">
<FRAME name="hidden" src="bottom.jsp" >
</FRAMESET>
bottom.jsp
==========
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<script LANGUAGE="JavaScript">
function refreshFrame() {
parent.frames["main"].loca
}
</script>
<script type="text/javascript">
function refresh()
{
//while(true)
//{
setTimeout("refreshFrame()
//alert("hi");
//Sleep(5000);
//}
}
</script>
</head>
<body onload="refresh()">
GRRR...
<%
java.util.Date d=new java.util.Date();
out.println(d);
%>
</body>
</html>
top.jsp
========
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
HELLO
problem withn the above code.
1) HELLO is not printed immediately.
2)FLICKERING is there. status bar is filling very quickly. odd looking ....it seems as silimilar if i would have used html-refresh.
question :
==========
How can i remove flickering ?
should i use iframe instead of ordinary frame to remove flickering ?
i am not interested to use AJAX,APPlet because those things i have learnt already.
i am stuck with hidden frames and page refreshing in JSP without page flickering.
can u provide me a better example ?
regards
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
look at the last comment
http://forum.java.sun.com/
i tried to do same like that. but thats not working
Ok, as a quick test, I did this:
main.html:
<FRAMESET ROWS="50,50">
<FRAME name="main" src="top.html" id="bottom">
<FRAME name="hidden" src="bottom.html" >
</FRAMESET>
top.html:
<html>
<body>
HELLO
</body>
</html>
bottom.html:
<html>
<head>
<script LANGUAGE="JavaScript">
function refreshFrame()
{
parent.frames["main"].loca
}
function refresh()
{
setTimeout("refreshFrame()
}
</script>
</head>
<body onload="refresh()">
<script language="JavaScript">
document.write( new Date().toGMTString() ) ;
</script>
</body>
</html>
And that seems to work ok (on firefox)
Does it not work on your machine?
>> so, to get the page refresh i should use only
No, it will give you the same result as javascript (see my html pages I posted)
still flickering :-(
To get it to stop after 30 seconds, you'd have to have another frame, which had a javascript counter in it.
Decrement the counter each time the page is loaded, and stop calling the refreshing timer if the counter is 0
Could get a bit messy... but I can't think of a cleaner way off hand :-(
Tim
its really messy.
just go to
http://www.sidestep.com/ai
enter LON to AMS
then" search"
now see how the pages are getting refreshed. excellent ...is not it ? no flickering.
i wanted to do something like that.
from the view source, i see they are probabily using AJAX. well, but some sites dont use reall AJAX ( i dont remeber the example site ) but gets the same output.
i like that.
html-refresh can not provide that kind of nice page refreshing.
Yeah, that page has:
new Ajax.Updater
lines in it, so they are using AJAX to query the database, then using javascript to update the webpage as the results come back
like:
<div id="results"></div>
<script language="javascript">
getElementById( "results" ).innerHTML += "<br>Woo!" ;
getElementById( "results" ).innerHTML += "<br>Cool!" ;
</script>
(replacing "woo" and "cool" with real data as it comes back from the server of course) ;-)
Tim
ahh...its working.
ok..fine.
here i am back..
You know, the big problem(i dont like) is the XML parsing in the client side by javascript in AJAX. server side returns a XML response and the clent side javascript parse that xml and update the DOM as similar you have given an example above.
may be i am not comfortable with the XML parsing with the javascript in the client side and update the HTML DOM.
can you tell me a tutorial for that ? i saw w3schools any other good tutorial link .... ?
As you are a classic programmer, so what do you suggest ? AJAX would be a good solution for JSP page refreshing ? i want to get my page refreshing as similar as to that site i have referred.
Now, coming back to ur response.
>>(replacing "woo" and "cool" with real data as it comes back from the server of course) ;-)
but your "woo" and "cool" are not XML data ! its a text data...server can not return text data in AJAX. it returns XML response and javacript parse that XML.
did you just show this example for simplicity without server's XML response?? or it could be a real situation where server can return plain text data ?
Have you had a look at DWR?
It allows you to call java methods (which can return String) on the server from javascript on the client:
http://getahead.ltd.uk/dwr
You basically, write java classes, install a servlet, and DWR generates the javascript you need to call those classes
>Have you had a look at DWR?
yes. i looked that. but could not understood that.
yea, i read their documentation ..but still i could not .
>It allows you to call java methods (which can return String) on the server from javascript on the client:
>http://getahead.ltd.uk/dw
>You basically, write java classes, install a servlet, and DWR generates the javascript you need to call those classes
can you please provide me an example using DWR how do i get a similar feature like the sites i have referred.
i think you have understood the problem. you take a very simple example to show that kind of feature.
i believe Ajax is god but its very diificult to update the DOM.
i want to get a similar feature as the site i have mentioned.
can you show me a small example on that ?
Ok, here's a quick DWR example...
Set up DWR as it explains in the installation guide.
Then, write a bean like this:
package ajaxtest ;
public class ServerTimeBean
{
public ServerTimeBean() {}
public String getTime() { return new Date().toString() ; }
}
compile it, and copy it to /WEB-INF/classes/ajaxtest
then, write WEB-INF/dwr.xml like this:
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
"http://www.getahead.ltd.u
<dwr>
<allow>
<create creator="new" javascript="ServerTimeBean
<param name="class" value="ajaxtest.ServerTime
</create>
</allow>
</dwr>
then, write your frame like this:
<%@ page contentType="text/html; charset=UTF-8" %>
<html>
<head>
<title>DWR Test</title>
<script type='text/javascript' src='/dwr/interface/Server
<script type='text/javascript' src='/dwr/engine.js'></scr
<script type='text/javascript' src='/dwr/util.js'></scrip
<script type='text/javascript'>
function refreshFrame()
{
DWRUtil.setValue( 'd1', ServerTimeBean.getTime() ) ;
setTimeout("refreshFrame()
}
</script>
</head>
<body bgcolor="#ffffff" onload="refreshFrame()">
<span id='d1'></span>
</body>
</html>
That *should* work...
I haven't tested it, but will do so if you get any problems with it :-)
Tim
Tim...i saw your solution (will go for testing shortly).its very promising. you are refrsing the System time every 5 secs interval in this code
<body bgcolor="#ffffff" onload="refreshFrame()">
<span id='d1'></span>
</body>
but you know, my server will return XML data. say after 5 secs in returned 5 XML then there would be 5 tables. say after 10 secs my server will return 10 XML(total) so 10 tables will be displayed.
if i do as above then only one table would be displayed...is not it ?
but look at the site i have referred which keeps on adding XML data into tables and showing more results.
but the code here
<body bgcolor="#ffffff" onload="refreshFrame()">
<span id='d1'></span>
</body>
can show only one value.
I was just giving you a simple example of how DWR can be used to fetch the time as a String asynchronously from the server...not reproducing the website you linked to...
I think you would need to implement a few methods in a java class:
startProcessing( parameters )
get Progress()
getLatestResults()
so when a user posts their search parameters, you call startProcessing, which starts the server looking for data
every X seconds, you can call getProgress to see how far along you are, and getLatestResults to return you the new objects found since the last time it was called
Then, you should be able to append these new results to the existing ones in the div...
Tim
>you should be able to append these new results to the existing ones in >the div...
but how do i add 5 tables containing different results ?
div id="results"></div>
<script language="javascript">
getElementById( "results" ).innerHTML += "<table border="0"
cellpadding="0" cellspacing="0" width="100%"> <tbody><tr> <td id="resultCardTopLine"><ta
" ;
getElementById( "results" ).innerHTML += "another table like above" ;
getElementById( "results" ).innerHTML += "another table like above" ;
</script>
i posted as above just to show how messy this is. because we are mixing JS + HTML+ CSS all these stuff...its horrible inside JS.
probabily, i would better stick with flickering solution. i.e with html meta-refresh/ javascript setTimeout ...can i have a stop button on my page to stop refreshing ?
you told "...To get it to stop after 30 seconds, you'd have to have another frame, which had a javascript counter in it.
Decrement the counter each time the page is loaded, and stop calling the refreshing timer if the counter is 0..."
how to do it ? any small example?
hi, Tim r u there ? have u seen
do u have yahoo account ?
http://farechase.yahoo.com
they are also doing the same thing ...but they are not using AJAX ! there page does not flicker .
>> ...but they are not using AJAX !
Yes they are...
this.req=new XMLHttpRequest();
(from http://re2.farechase.yahoo
Tim, my biggest concern is i can not display the XML output . the XML has to be parsed by the JS and then would be displayed in tables . so , if i have 5 different XML . then i have to parse those 5 XML's and then those 5 XML data would be displayed in 5 tables as you see in the referred site i mentioned. this kind of display is a very tough thing.
Howeve, another solution i have found in the net which claims
".......Split your window frame in 2 parts - one part will be displaying
the current page and another part should have a hidden page. Every
time you need to refresh the page, submit the hidden page data and use
the hidden page data fetched from server to show new content. that is
use hidden page for communication with server.............."
do u think this can remove flickering ?
if you think so, please provide me an example to test. i would prefer this because i can then use java beans in my JSP page. and i shall parse XML data and store the data into the bean in the server side. and display those data in my JSP hidden page.
i like this method. i tested but could not remove the flickering....may be my coding was wrong . can you try ? can you tell if i follow the above comments , it would remove flickering ?
Basically you have three options:
1) Use a hidden/second frame, and load data this way. This will cause the progress meter to appear (flicker) as the data is loaded
2) Use basic AJAX, and parse the XML to generate HTML (no flicker)
3) Use DWR (or another similar framework). This will allow you to build html on the server and just display it (see my DWR example) with no flickering
Tim
>This will allow you to build html on the server.
problem is here. server could build html...no problem. but if there is html + css + table ete etc....then how much messy it would be.
you know, say i have made a nice looking html table as like above .
server could sent this table by two ways...
1) out.println("a big nice looking table with css");
problem here would be, table would be very big and also have to take care of ESCAPE character.
2) DWRUtil.setValue( 'd1', ServerTimeBean.getTime() ) ;
so, DWR is sending a server side component here, may we could send a table from the serverSide...same thing.
you know what could have been the best thing ....if we can have a html table in JSP ...and server would just put the data into it. thats the best option.
but server can not do this . server have to produce tables for as many as XML there would be. so it has to produce tables ...and producing a NICE looking tables from the bean class or out.println() is tedious.
i am interested in your flickering solution (with frames) in your reply no 2
could you add one fucntionality there ?
1) refreshing would stop after 50 secs automatically.
2) there would be a stop button but in between 0-50 secs , if one user press the "stop" button , a boolean varible would be made false in the server side and it would stop refreshing
Excellent Rating to you.
i did smething like that. i did not use AJAX or DWR .. it was bit unconvenient to parse the big XML in the client side.
so, i chose the first solution i.e page refresh....my page refreshes and the irritating status bar is shown.
Anyway, i wonder some people says using iframe this could be managed ! i do not know how they are managing.
thanks
Business Accounts
Answer for Membership
by: TimYatesPosted on 2005-10-26 at 03:03:40ID: 15160990
How about:
bottom.jsp
-------------
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<meta http-equiv="refresh" content="5">
</head>
<body onload="">
GRRR...
<%
java.util.Date d=new java.util.Date();
out.println(d);
%>
</body>
</html>