This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

updating web page with events  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to display text received from a serial device dynamically on a page. I wrote Java code that creates an event whenever one line of text is received. I am having difficulty in understanding how to implement a web-based listener that displays the lines on a page as they are received.
Desired functionality is something like this:
1) Client browser is pointed to the server URL
2) User gets N lines of text and displays them
3) A text available event is received at the server
... My code goes here
4) The new line is shown on client's browser, i.e. it now shows N+1 lines
5) Another text available event is received... etc

I am new to servlets and web programming so any help will be much appreciated.
Thanks,
Cuney
 
Author and ninkuma
Marshal
Posts: 66804
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The request/response cycle of HTTP is ill-suited to your needs.

Perhaps an Applet solution would make the most sense.

Otherwise, you'll need to have your pages poll the server periodically; perhaps employing Ajax.
[ November 18, 2008: Message edited by: Bear Bibeault ]
 
Cuneyt Taskiran
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A colleague mentioned Java Message System. Would JMS be able to handle this functionality? Would it be an overkill?
Thanks,
C
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66804
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JMS can do nothing to help the client update -- unless it's usable from an Applet (I have no idea).
 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear ,

Why can't we go for Observer pattern in this situation ??
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why can't we go for Observer pattern in this situation ?


It is a form of Observer. But HTTP connections have a limited time of life, and can't be initiated by the server. The Observable (on the server) can't push notifications to the Observer (the browser) if there isn't a connection at that time. This can only happen the next time the browser polls the server.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dittmer , that explains me a lot.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!