I would like to show real time data on a web page means as soon as it processed by the model the request.setAttribute("abc", object); will set the attribute and it will immediately be take away by the getAttribute methord in jsp. I require this form of information flow but i dont know how to achieve it , would some one shed light as to how we can do that.
it might be acheived through ajax as this technology is used to update the webpage without refreshing the page and all the communication is in the background. but I dont know how to use ajax.
I am using servlets, jsp and tomcat and doing it in MVC architecture.
It will be easy if some one from coderanch throw some light in this regard.
what I am doing overall is simple:
model ----->(processing data) ----servlets (setting the data) ------>jsp (view it). so I just want to show in the view that is jsp as the data is processed by the model. and right now what happens is every thing is working fine but when i hit the submit button on the html page, browser window hangs until all the processing is done by the models (while loop) and when it ends, it shows all the data on the webpage.
zishan khan wrote:but I dont know how to use ajax.
Now you know what your next task is.
You cannot achieve actual real-time data, but with Ajax you can periodically contact the server to fetch the latest data set to update the page.
Be aware of the limitations of your server. 10,000 clients requesting updates every 3 seconds is going to hammer the server pretty badly.
well, how to contact the server periodically to fetch the latest data set through ajax, would you please let me know any example or code snippet will be helpful.
Ajax is a large subject and a forum topic isn't going to give you what you need. I suggest getting started reading... perhaps starting with this article.
zishan khan wrote:cannot achieve the real time data!!. bear, if that is right than how can twitter and fb sends the real time tweets and messages. i mean there must be some technology out there?
They don't send real-time information. If you try sending a tweet or a Facebook message, you'll see there is a fraction of a second required to do that. That isn't "real-time". And you can achieve sub-second response time too if you program accordingly. Just don't throw around technical terms like "real-time" unless you know what they mean.
but you can try Session and Request Event Listeners that are available. Try if they can be put to use in effective way to solve your problem
URL to Event Listeners - >http://download.oracle.com/docs/cd/B14099_19/web.1012/b14017/filters.htm#i1000654