Posts Tagged ‘http’

RESTful Web Services the easy way with JAX-RS

September 15, 2009

Here are the slides that I have prepared for my talk at JavaForum this evening. It took me some time to cut it down to 34 slides and then still many of them had to become extra spare slides. I had to realize that 30 minutes is really not much time. On the other hand I’ve seen many 10 minute lightning talks where the speaker manages to deliver the essence of a pretty complicated topic, so I shouldn’t really complain.

REST presentation

June 16, 2009

I have put together some slides about the basic principles in REST. The real presentation is actually implemented as a JAX-RS application. I started out with a django version, but I needed a Java-angle on it so I had to switch to JAX-RS.

Shouldn’t the web be location aware by now?

January 4, 2009

More and more devices come with built in GPS and mobile browsing has become more popular with the iPhone and all the ultra mobile laptops such as the Asus EEEPC. So, mow it seems to be the right time to start building websites that adapt themselves to your current location.

To make the web applications location aware we need to get the location from somewhere. The most obvious way would be that the web browser makes it available by retrieving it from a GPS, mobile cell information, WiFi access point etc. It can provide the information to the web applications through a JavaScript API.

What is available?

Unfortunately there is no standard that is supported by all the major browsers yet, but there are some really interesting things ongoing.

For Firefox you have the Geode plugin that provides access to location information via a JavaScript API. The location information in Geode is based on Skyhook which calculates it from nearby WiFi access points. Skyhook has a database with MAC addresses of access points, mostly in USA and Canada.

The Firefox 3.1 beta release includes out of the box support for a JavaScript API. Firefox 3.1 will allow the user to choose a geolocation service provider, which can either be a peripheral device like a GPS, or a web-based service provider. The API is based on the W3C draft described below.

Google has done quite some work to location enable the web. As announced in their code blog they provide an AJAX API that lets you get a rough location based on the ip-address. Google Gears also supports a location API very similar to the W3C draft and with Google as editor in W3C I think the chance of conformance is rather good. Google Gears can use GPS, mobile cell id or WiFi access point to determine the location. As you probably know Gears is available as a plugin for Safari, Firefox and IE and of course comes built in to Chrome. Also Windows Mobile 5 and 6 devices are supported and of course it comes pre-installed on Anrdoid phones.

The IPhone does currently not provide any JavaScript API for location information and it does not support Google Gears. There is however an application available for Jailbroken IPhones that implements the W3C draft API described below.

The W3C Geolocation JavaScript API draft

Google has submitted a simplified version of their Google Gears API to W3C. This draft specification is currently worked on in the Geolocation Working Group in W3C. The working group plans to have an official recommendation ready by end of 2009.

The current draft version of this API includes a method for getting location information and another to get periodic updates of location information.

Example of a “one-shot” position request.

    // Callback function
    function showMap(position) {
      // Show a map centered at
      // (position.coords.latitude, position.coords.longitude).

    // One-shot position request.

Example of requesting repeated position updates.

    // Callback function
    function scrollMap(position) {
      // Scroll the map so that it is centered at
      // (position.coords.latitude, position.coords.longitude).

    // Request repeated updates.
    var watchId = navigator.geolocation.watchPosition(scrollMap);

    function buttonClickHandler() {
      // Cancel the updates when the user clicks a button.