wood burning stoves 2.0*
The moose likes Servlets and the fly likes getting real time data on a web page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "getting real time data on a web page" Watch "getting real time data on a web page" New topic
Author

getting real time data on a web page

zishan khan
Greenhorn

Joined: Jan 28, 2011
Posts: 16
hi,

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.



thank you

zishan
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
zishan khan
Greenhorn

Joined: Jan 28, 2011
Posts: 16
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?

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.

regards

zishan
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

If you really need real-time, you'll need to use other technologies in addition to just HTTP.

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.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

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.
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1212
    
    1

as mentioned in all above posts, i agree, getting real time data is difficult.
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

~ abhay
 
jQuery in Action, 2nd edition
 
subject: getting real time data on a web page