reliable. There are a few limitations, however. For example, an App Engine application
can only access other resources on the web that are exposed over port 80 (HTTP) or port
443 (HTTPS). App Engine can't fetch URLs from non-standard ports or arbitrary port
assignments. For the basic request-and-response scenario that we'll be looking at in this
chapter, it doesn't make sense, but it's important to realize that your application is not
actually communicating over a socket to the other systems on the web. As URLFetch is a
service that runs on Google's infrastructure, your application is just invoking this service.
Consider the code in Listing 8-4. These two lines use the standard java.net
namespace to fetch the response from a given URL. In this case, you're fetching the
response from http://www.google.com. You are capturing the response by opening
a stream to a new BufferedReader object. If you were to print this back to the screen,
it would render what appears to be the Google landing pageGoogle landing page.
However, by examining the URL in the browser's navigation bar, you will notice that
you're still pointing to the App Engine application. See Figure 8-5 for an example of an
App Engine application using URLFetch to retrieve the Google landing page.
Listing 8-4. URL Fetch
URL url = new URL(" http://www.google.co m/");
BufferedReader reader = new BufferedReader(new
Figure 8-5. Fetching google.com