Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting real time data on a web page

 
zishan khan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
zishan khan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic