December 2017
Intermediate to advanced
372 pages
8h 46m
English
So far, all of our client examples have either used the curl command-line utility or the JAX-RS RESTful web server client API. It is very common to use JavaScript code running on a browser as a RESTful web service client, therefore, in this section, we will take that approach. The following example illustrates an HTML/JavaScript client receiving server-sent events:
<!DOCTYPE html> <html> <head> <title>Stock Ticker Monitor</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body onload="getStockTickerValues()"> <h2>Super fancy stock ticker monitor</h2> <table cellspacing="0" cellpadding="0"> <tr> <td>ENSD Stock Ticker Value: </td> <td> <span id="stickerVal"></span></td> ...