I want to build realtime application using java. The web application always request data to server every 10 seconds, and display the fresh data on the web page.
do you have idea how to solve case like this ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ajax will make your JavaScript code poll your site server to get the last value of the currency, say every 10 seconds. Meaning if 100 persons are connected, you’ll get on average 100 accesses in 10 seconds.
Unless you use a Flash object or a Java Applet to establish a TCP-IP connection with your server (that can push the new value when it is available), Ajax is a better/easier option for you. The TCP alternative provides faster results (clients see the new value more in real time than with Ajax polling), and, usually, more efficient in terms of performance (Only push when a new value is available).
If you implement an Ajax polling system, you’ll have to add server side an abuse detector: many people understand well JavaScript and some of them may change the polling frequency to have newer values faster… (like every second). Depends on the audience, the number of people accessing your site etc…
That detector would ensure that a given client does not exceed the polling frequency (e.g. more than once every 12 seconds, if the frequency is 10, with an error margin)