Conclusion


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.

This project starts by getting the user's ZIP Code. The online version uses cookies, URL encoding, and an HTML form to get and store the user's ZIP Code; the desktop version uses a dialog box and a file, zip.txt, to get and store the ZIP Code.

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.



    Java After Hours(c) 10 Projects You'll Never Do at Work
    Java After Hours: 10 Projects Youll Never Do at Work
    ISBN: 0672327473
    EAN: 2147483647
    Year: 2006
    Pages: 128

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net