Skip to main content

New Article: HTML5 Server-Push Technologies, Part 2

Posted by editor on April 26, 2010 at 11:57 AM PDT

We've just published the second and final part of Gregor Roth's series, HTML5 Server-Push Technologies, Part 2. In this part, Gregor goes into detail about the new HTML5 WebSockets protocol, then presents conclusions regarding both WebSockets and Server-Sent Events (covered in detail in Part 1 of the series).

Gregor introduces WebSockets as a technology that:

enables establishing a bidirectional communication channel. In contrast to Server-Sent Events, the WebSocket protocol is not build on top of HTTP. However, the WebSocket protocol defines the HTTP handshake behaviour to switch an existing HTTP connection to a lower level WebSocket connection. WebSockets does not try to simulate a server push channel over HTTP. It just defines a framing protocol on top of TCP. In this way WebSockets enables two-way communication natively.

WebSockets provide a capability to transmit data within a sub-protocol over HTTP. Data is transferred in WebSocket "frames" that include either text (delimited by a starting 0x00 byte and an ending 0xFF byte) or binary data (binary frames start with 0x80 and a set of bytes that define the length in bytes of the binary data that follows).

Gregor notes that:

Because JavaScript cannot operate with binary data represented as a byte array, the binary frame type is limited to be used for languages other than JavaScript. In addition the binary frame and text frame, new frames types can be introduced by future releases of the WebSocket protocol specification. WebSocket's framing is designed to support new frame types. A connection can be closed at any time. No extra end-of-connection byte or frame exists.

One of the primary advantages of both Server-Sent Events and WebSockets is that the protocols provide for transmission of data with very low overhead (unlike Comet protocols like Bayeux and BOSH). Gregor provides examples of HTTP requests and responses that embed WebSocket protocol data, and provides example Java client and server examples that show how to implement a WebSockets-based application.

In his conclusion, Gregor summarizes the differences and similarities between WebSockets, Server-Sent Events, and current Comet protocols. He then offers a prediction:

What do WebSockets and Server-Sent Events mean for popular Comet protocols such as Bayeux and BOSH? The HTML5 communication standards have the potential to substitute for the classic Comet protocols and become the dominant server-push technology, at least for new applications.

For a thorough introduction to the new HTML5 WebSockets protocol, read Gregor's HTML5 Server-Push Technologies, Part 2.


In Java Today, Terrence Berr reviews last week's significant releases in JavaFX 1.3 and NetBeans 6.9 Beta released:

A few days ago JavaFX 1.3 as well as NetBeans 6.9 Beta were released, featuring a host of significant improvements in many areas. I won’t be covering all the the changes but will highlight the most important ones and provide pointers to more information. So, let’s dive in: JavaFX 1.3 improvements...

Michael Huttermann presents Agile ALM: Additional information, discussions, source code, ..:

I have created a project on Kenai to host accompanying sources for my book Agile ALM. I added configuration and test scripts to demonstrate discussed concepts, where appropriate. Some of the scripts are contributed by the leading experts of the covered topics, others were created in close collaboration. In my book, one of the major tool backbones is Maven. As a result, most of the provided scripts are Maven scripts. Much more details will follow...

Dustin Marx posted Effective Exception Handling is Covered Effectively in Effective Java:

I recently wrote that the chapter in Effective Java devoted to exception handling has been one of the most influential software development chapters I have read. The value of this chapter was reinforced by Elliotte Rusty Harold's blog post Bruce Eckel is Wrong. Harold's main assertion is that Eckel was wrong to write that checked exceptions must be caught at time of encounter because they don't necessarily need to be caught if they are declared as part of the method's throws clause...

Kirill Grouchnikov describes Using Flamingo 5.0 command buttons to build a breadcrumb bar:

Flamingo component suite began its life in January 2006 when Rick Jeliffe of Topologi has contacted me and proposed to open-source their own implementation of the breadcrumb bar component. In the years since i have hacked at different pieces of the breadcrumb bar implementation. As with any significant piece of code that you get to maintain and extend, it takes some time to find your way around the code, and this was no exception...


In the Weblogs, John Ferguson Smart describes Grouping tests using JUnit categories:

In a well-organized build process, you want lightning-fast unit tests to run first, and provide whatever feedback they can very quickly. A nice way to do this is to be able to class your tests into different categories. For example, this can make it easier to distinguish between faster running unit tests, and slower tests such as integration, performance, load or acceptance tests. This feature exists in TestNG, but, until recently, not in JUnit. Indeed, this has been missing from the JUnit world for a long time...

Juliano Viana talks about Cloud Appreciation:

My 3 years old MacBook Pro went suddenly dead this week. Annoying as it is, this event allowed me to experience cloud computing like never before. This notebook has been my main computer for the past 3 years. I used it for everything and carried it around wherever I went. One day this week I was using it with tons of apps open as usual (I am known to never close anything...why do we have 4GB RAM for anyway?). I closed the lid without powering off (as I always did) , put the notebook in my bag and went out of the office. A few minutes later, before even getting out of the building, I remembered I had forgotten to send an important email. I then came back to my desk and opened the lid again, but the screen remained dark. As it turns out it would remain dark forever...


In the Forums, macadams is working on a Jsf table, datasourc and glashfish display problem: I bind a mysql datasource to a netbeans visual-jsf table, it displayed fine on my system, but when i hosted the site on glashfish v2 the tables does not display. I have dumped my sql script on my cpanel and tried to configure glassfish but there seem to...

In the LWUIT forum, sachinnevase asks for help with :: TextField AutoComplete / AutoSuggestion ::: Hi Friends, I have a list of U.S States and wish to a have a feature,that will allow user to enter first few characters in textfield and show a filtered list of states starting with the characters entered something similiar to google search...

jay_b asks about JAX-WS Streaming Compatibility With Other Web Service Frameworks: I have a web service where I can potentially return a very large attachment. Ideally, I'd like to use JAX-WS MTOM streaming to send the attachment back to the client. Chances are the majority of the consumers of this web service will use .NET and Java to...


Our Spotlight this week is the NetBeans IDE 6.9 Beta Release:

NetBeans 6.9 Beta introduces the JavaFX Composer, a visual layout
tool for visually building JavaFX GUI applications, similar to the Swing
GUI builder for Java SE applications. Additional highlights include OSGi
interoperability for NetBeans Platform applications; support for JavaFX
SDK 1.3, PHP Zend framework, and Ruby on Rails 3.0; as well as
improvements to the Java Editor, Java Debugger, and issue tracking, and
more. NetBeans 6.9 Beta is available in English, Brazilian Portuguese,
Japanese and Simplified Chinese, as well as in several
community-translated languages. Learn more: http://netbeans.org


This week's java.net Poll asks What is the most important enhancement in JavaFX 1.3? The poll will be open through Friday.


Our latest Feature Article is HTML5 Server-Push Technologies, Part 2 by Gregor Roth; this two-part series explains the new Server-Sent Events and WebSockets API in HTML5. We're also featuring Biswajit Sarkar's Using Styles, Themes, and Painters with LWUIT, in which you discover how to use some of the new and enhanced features in LWUIT version 1.3; and Dibyendu Roy's Rethinking Multi-Threaded Design Principles, Part 2, which provides guidance on how to harness the processing powere of next generation multicore processors.


Current and upcoming Java Events:

Registered users can submit event listings for the java.net Events Page using our events submission form. All submissions go through an editorial review before being posted to the site.


Archives and Subscriptions: This blog is delivered weekdays as the Java Today RSS feed. Also, once this page is no longer featured as the front page of java.net it will be archived along with other past issues in the java.net Archive.

-- Kevin Farnham

O'Reilly Media
Twitter: @kevin_farnham