views:

51

answers:

3

I am creating a e-learning application , where the students (wireless) connect to the teachers machine, the teacher hosts a tomcat server.

the teacher has a set of HTML web-pages(each of which can be thought of as a slide). and the students can view a web slide-show on his/her browser...

the problem is.... i want the pages on the students browser to be redirected according to the teachers input..

in short: i want the server to automatically redirect all the client browsers to the next page when the teacher wants it to be so...

how do i do it??

[i am using JSP/javascript/Java/Tomcat/Eclipse]

A: 

You could use ajax push from tomcat using one of the Java Server Faces component libraries like PrimeFaces. This would require that you install the JSF and PrimeFaces jars in an appropriate web application that could control the ajax push. Most of the code has already been written for you ... it's just a matter of wiring it up to your slide material.

Here is an example of ajax push using this technology ... you can just open up a bunch of browsers on different computers and watch them get the push: http://www.primefaces.org:8080/prime-showcase/ui/chat.jsf

You can get the source code for the example above from here: http://repository.prime.com.tr/org/primefaces/prime-showcase/1.0.0-SNAPSHOT/prime-showcase-1.0.0-SNAPSHOT.war. Just drop this war in your tomcat's "webapps" directory and restart tomcat. You will then be running these examples yourself. The source code .java files for all of the examples are in the .war file

And the source code for the PrimeFaces jar file here (if needed): http://code.google.com/p/primefaces/source/checkout

The ICE Faces folks also have a nice explaination of Ajax push in case that is not clear: http://www.icefaces.org/main/ajax-java/ajaxpush.iface

And here is another open source solution that should be able to do this also: http://www.ape-project.org/

Vernon
Although JSF is nice, it is **not required** to get Comet to work. The OP also doesn't seem to have any JSF knowledge yet and using JSF for that would only introduce another *steep* learning curve to solve this problem.
BalusC
Every technique I suggested uses Comet.
Vernon
thank you very much for you answer, it will solve my problem
Gnome Guru
A: 

I agree with Vernon's answer.

But i can think of a naive approach to fulfilling your requirement. Have your client webpage, poll a servlet through AJAX, that will return say, status=changed;newURL=<newURL> .

Use your javascript function to analyse this AJAX response, and if status=changed,, do a location.href=<newURL>.

Take a judicious choice on the poll interval time, based on the average expected frequency of slide show updates.

The Machine
A: 

Thus, you basically want to PUSH the request to the client? You could make use of the Comet technique. It is supported by Tomcat, also see this document, it includes code examples as well. Don't forget to configure Tomcat first to use the NIO Connector.

BalusC
thank you for your advice, really helped me....
Gnome Guru