|
| By Tamil Vengan, April 2, 2007 |
|
| |
Ajax is a popular Web 2.0 technology that includes but is not limited to Asynchronous JavaScript and XML: Ajax derives its name from those two entities. A mashup is a Web site or application that combines content from multiple sources. Hosted with this article is a sample application developed with Ajax and a mashup (henceforth, the sample), which you can experiment with or modify. Also, this article shows you how to compile the sample and deploy it on Sun Java System Web Server 7.0 (henceforth, Web Server 7.0), Sun's latest Web server release.
The sample displays the latest news, weather, stock-quote, traffic, and map information; also the results of user-initiated searches for videos, blogs, and photos. Besides Ajax and a mashup, key to the development of the sample are Really Simple Syndication (RSS) software and public Web-service APIs from Google, Yahoo!, Flickr, YouTube, and
Upcoming.org. For details of the sample's capabilities, see the
appendix, which also includes an 8-minute Flash demo.
You might want to first watch the demo to become acquainted with the application before stepping through the setup, compilation, and deployment procedures.
Notes:
| |
| - | Setting Up the Sample |
| - | Obtaining and Updating License Keys |
| - | Compiling the Sample |
| - | Deploying and Running the Sample |
| - | Appendix: The Sample |
| - | Conclusion |
| - | References |
| |
| |
First, download and set up the sample:
AJAX_SAMPLE_DIR.
ajax.zip file to the
AJAX_SAMPLE_DIR directory.
| |
Now sign up on and obtain license keys from the sites that offer the Web-service APIs:
1 This is a URL-based key. For example, if you designate your sample's URL as
http://localhost:84/ajax, request a key for the
http://localhost:84.
The process is straightforward and takes only a few minutes.
The license keys that reside in the
AJAX_SAMPLE_DIR/docroot/js/setup.js file that you downloaded are for demos only. To run the sample, edit that file and update the license keys, as follows:
|
API
|
Variable Whose Value You Replace With That of Your License Key
|
|---|---|
| |
|
|
Yahoo! Developer Network
|
yahooKey
|
|
Google Maps
|
googleKey
|
|
Flickr Search
|
flickrKey
|
|
YouTube Developer
|
youTubeKey
|
Upcoming.org
|
upcomingOrgKey
|
| |
|
| |
Before compiling the sample, set two environment variables:
JAVA_HOME environment variables to the location of the Java 2 Platform, Standard Edition (J2SE Platform) SDK 1.4 or a later release.
JAVA_HOME/bin to the
PATH environment variable.
Now compile the sample,
AjaxServlet.java. The compilation involves the following JAR files:
AjaxServlet.java, that is, those in
Web-Server-install-dir
/lib/pwc.jar, where
Web-Server-install-dir is the location of Web Server 7.0, for example,
/sun/ws7.0.
googleapi.jar,
rome-0.9.jar, and
jdom.jar, all of which reside in the
AJAX_SAMPLE_DIR/docroot/WEB-INF/lib directory.
To compile
AjaxServlet.java and create the Web archive (WAR) file:
AJAX_SAMPLE_DIR directory.
% javac -classpath
Web-Server-install-dir
/lib/pwc.jar:./docroot/WEB-INF/lib/rome-0.9.jar:
./docroot/WEB-INF/lib/googleapi.jar:./docroot/WEB-INF/lib/jdom.jar:. -d ./docroot/WEB-INF/classes AjaxServlet.java
: to
;.
AjaxServlet.class, to the
AJAX_SAMPLE_DIR/docroot/WEB-INF/classes directory.
% cd docroot
% jar cvf ../ajax.war *
ajax.war file resides under
AJAX_SAMPLE_DIR.
| |
Deploy the
ajax.war file from the Web Server 7.0 Administration Console, as follows:
ajax.war file and type
/ajax for the URI. Click OK.
Finally, run the sample: Go to
http://
Web-Server-hostname
:
Web-Server-portnumber
/ajax, for example,
http://localhost:84/ajax.
| |
Watch this Flash demo of the sample.
A summary of the capabilities follows.
General UI and Settings
The sample displays a clock and a calendar
at the top right corner. Note also these highlights:
Sorry not found message.
News
Note these highlights:
Weather
Yahoo Weather is the default RSS feed for the Weather window. The sample displays a weather report for the location denoted by a U.S. zip code or address that you entered and updates the information after an elapsed refresh interval.
The default ZIP code is 95014. The default refresh interval is 5 minutes.
Stock
The Yahoo! Stock Quote Service supplies information for the Stock window. Note these highlights:
SUNW,
CSCO,
ORCL,
GOOG,
IBM,
HPQ,
YHOO, and
EBAY. The default refresh interval is 30 seconds.
Traffic
The
Yahoo traffic Representational State Transfer (REST) API supplies information for the Traffic window. Note these highlights:
Maps
The
Google Maps API supplies information for the maps in the content window. Note these highlights:
Videos
The
Google Ajax Search API supplies information for videos in the content window. Note these highlights:
Blogs
Google Ajax Search API also supplies information for the blogs in the content window. Note these highlights:
Photos
The
Flickr API supplies information about the photos in the content window. Note these highlights:
YouTube Video Search
The
YouTube REST API supplies information for the YouTube Video search results in the content window. Note these highlights:
Web Search
The
Google Search API and the
Yahoo! Search API together create a mashup for information for the Web search results in the content window. Note these highlights:
Live Traffic
The
Google Map API and the
Yahoo! Traffic API together create a mashup for live traffic information in the content window. Note these highlights:
Local Events
The
Google Map API and the
Upcoming.org API
together create a mashup for information on local events in the content window. Note these highlights:
Upcoming.org) (Mashup) from the drop-down menu at the top.
Local Maps
The
Google Map API and the
Yahoo! Local Search APIs together create a mashup for the information on local maps in the content window. Note these highlights:
pizza) in the right text field. Click
| |
Ajax and mashups enable the creation of versatile and content-rich Web applications. Sun Java System Web Server, with its stability, scalability, and numerous capabilities that facilitate ease of development, is the best platform for developing and deploying such applications.
| |
