This chapter presented the Forecaster project, the finale to the 10 projects presented in this book for some Java fun. This was a particularly powerful project, reading weather forecast data from the National Weather Service, graphing it, and reporting it to you.
There are two versions of this project: a JSP, forecast.jsp, for online use, and Forecast.java, for desktop use. One or the other of these files is all you need. The JSP file runs like any other JSP file on a Java-enabled server, whereas you can run the .java file on your desktop.
Forecaster then passes the ZIP Code to the National Weather Service website and reads the web page that is returned to scan for weather forecast data. The high and low forecasts for four days, starting with today, are stored in arrays.
That data is then graphed and displayed to the user. In the online version, the forecast graph is encoded as a JPEG image and sent to the browser; in the desktop version, the image is drawn using standard Java graphics techniques.