Web 2.0 Development with the Google Web Toolkit

The Google Web Toolkit allows for modern Web development using Java, without ever needing to write a single line of HTML or JavaScript.


<inherits name='com.google.gwt.http.HTTP'/>

to the example.gwt.xml file. We'll rewrite the main code and add a couple packages to do calls to servers that provide JSON output (see The Same Origin Policy sidebar). For this, add two classes to the client: JSONRequest and JSONRequestHandler; their code is shown in Listings 2 and 3.

Let's opt to create the screen completely with GWT code. The button will send a request to a server (in this case, Yahoo! News) that provides an API with JSON results. When the answer comes in, we will display the received code in a text area. The complete code is shown in Listing 4, and Figure 3 shows the running program.