Georgia Institute of Technology Making Text for the Web part 3 Barb Ericson Georgia Institute of Technology March 2006.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Introduction to Rails.
Advertisements

Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
The Web Warrior Guide to Web Design Technologies
Georgia Institute of Technology Making Text for the Web part 4 Barb Ericson Georgia Institute of Technology March 2006.
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Thursday, October 18, 2012 Session 7: PHP.
Georgia Institute of Technology Speed part 3 Barb Ericson Georgia Institute of Technology May 2006.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Server-side Scripting Powering the webs favourite services.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizard’s Guide to PHP by David Lash.
Writing Classes (Chapter 4)
Georgia Institute of Technology Creating and Modifying Text part 4 Barb Ericson Georgia Institute of Technology Oct 2005.
Georgia Institute of Technology Making Text for the Web part 5 Barb Ericson Georgia Institute of Technology March 2006.
PHP meets MySQL.
Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational.
Dynamic Web Pages & JavaScript. Dynamic Web Pages Dynamic = Change Dynamic Web Pages are web pages that change. More than just moving graphics around.
1 Basic Perl CGI Programming. 2 Issues How and when your program is invoked. Generating Response –HTTP Headers –HTML (or whatever document type you want)
McLean HIGHER COMPUTER NETWORKING Lesson 7 Search engines Description of search engine methods.
CPSC1301 Computer Science 1 Chapter 12 Creating and Modifying Text part 4.
Georgia Institute of Technology Making Text for the Web Barb Ericson Georgia Institute of Technology March 2006.
Georgia Institute of Technology More on Creating Classes part 2 Barb Ericson Georgia Institute of Technology Oct 2005.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CreatingClasses-SlideShow-part41 Creating Classes part 4 Barb Ericson Georgia Institute of Technology Dec 2009.
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
Class 1Intro to Databases Goals of this class Understand the architecture behind web database applications Gain a basic understanding of what relational.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Object Oriented Programming (OOP) LAB # 1 TA. Maram & TA. Mubaraka TA. Kholood & TA. Aamal.
Chapter 12© copyright Janson Industries Java Server Faces ▮ Explain the JSF framework ▮ SDO (service data objects) ▮ Facelets ▮ Pagecode classes.
Methods.
Georgia Institute of Technology Making Text for the Web part 2 Barb Ericson Georgia Institute of Technology March 2006.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
Georgia Institute of Technology Creating and Modifying Text Barb Ericson Georgia Institute of Technology June 2005.
For Friday Finish reading chapter 9 WebCT quiz 17.
Databases.
OO Design and Programming II I/O: Reading and Writing
Introduction to Dynamic Web Programming
File Input / Output.
Lecture 5 Text File I/O; Parsing.
Chapter 7 User-Defined Methods.
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
Exceptions: When things go wrong
Madlib-Input, Strings, and Lists in Scratch
C Functions Pepper.
Barb Ericson Georgia Institute of Technology May 2006
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Creating and Modifying Text part 2
PHP / MySQL Introduction
Testing and Exceptions
Starting Out with Java: From Control Structures through Objects
Lecture 11 C Parameters Richard Gesick.
Functions A function is a “pre-packaged” block of code written to perform a well-defined task Why? Code sharing and reusability Reduces errors Write and.
Unit 6 Working with files. Unit 6 Working with files.
Exercise 11.1 Write a code fragment that performs the same function as the statement below without using the crash method Toolbox.crash(amount < 0,
Chapter 15 Introduction to Rails.
Midterm 2 review.
Server-Side Processing II
HTML Links.
Workshop for Programming And Systems Management Teachers
Anatomy of a Java Program
Introduction to AppInventor
Making Text for the Web part 6
CodePainter Revolution Trainer Course
More on Creating Classes
Creating and Modifying Text part 3
Barb Ericson Georgia Institute of Technology Oct 2005
Chapter 10: Void Functions
Methods/Functions.
Barb Ericson Georgia Institute of Technology May 2006
CPSC 233 Tutorial 13 March 11/12th, 2015.
Presentation transcript:

Georgia Institute of Technology Making Text for the Web part 3 Barb Ericson Georgia Institute of Technology March 2006

Georgia Institute of Technology Using other Web Pages Sites like Google news create web pages by getting information from other web pages

Georgia Institute of Technology Adding the Current Temperature Let's add the current temperature to a Homepage Using the method getTempFromNetwork in class TempFinder –This is an example of reuse –Reusing working classes and methods is one of the advantages of object-oriented development

Georgia Institute of Technology Adding Temp to a Homepage public void writeHomepageV3(String name, String interests) { // get the current temperature TempFinder tempFinder = new TempFinder(); String urlString = " String currTemp = tempFinder.getTempFromNetwork(urlString) ; // try the following try { // open a file for writing BufferedWriter writer = new BufferedWriter(new FileWriter(name + ".html")); // write the start writeStart(writer); // write the header writeHead(writer,name + "'s Homepage"); // write the body writeBody(writer," Welcome to " + name + "'s Homepage " + " I am interested in " + interests + ". Right now it is " + currTemp + " degrees. "); // end the page writeEnd(writer); // close the writer writer.close(); } catch (Exception ex) { ex.printStackTrace(); }

Georgia Institute of Technology Testing the Addition of Temp Use the following main method to test the new method –In class WebPageWriter public static void main(String[] args) { WebPageWriter writer = new WebPageWriter(); writer.writeHomepageV3("Mark", "reading"); }

Georgia Institute of Technology The Unnamed Package If you don't specify what package your class is in at the beginning of your class file –Using the package xxx; statement before the class definition It is put in the "unnamed" package –A package without a name Both WebPageWriter and TempFinder are in the "unnamed" package

Georgia Institute of Technology Adding a Random Sentence We can reuse the method generateRandomSentence in class SentenceGenerator too –To add a random sentence to the generated Homepage Simply create an object of the class SentenceGenerator –And invoke the generateRandomSentence method –And use the result in the HTML page

Georgia Institute of Technology Add Random Sentence public void writeHomepageV4(String name, String interests) { // get the current temperature TempFinder tempFinder = new TempFinder(); String urlString = " String currTemp = tempFinder.getTempFromNetwork(urlString); // get the random sentence SentenceGenerator sentenceGen = new SentenceGenerator(); String sentence = sentenceGen.generateRandomSentence(); // try the following try { // open a file for writing BufferedWriter writer = new BufferedWriter(new FileWriter(name + ".html")); // write the start writeStart(writer); // write the header writeHead(writer,name + "'s Homepage"); // write the body writeBody(writer," Welcome to " + name + "'s Homepage " + " I am interested in " + interests + ". Right now it is " + currTemp + " degrees. " + " The random thought for the day is: " + sentence + " "); // end the page writeEnd(writer); // close the writer writer.close(); } catch (Exception ex) { ex.printStackTrace(); }

Georgia Institute of Technology Testing the Random Sentence Use the following main method to test the new method –In class WebPageWriter public static void main(String[] args) { WebPageWriter writer = new WebPageWriter(); writer.writeHomepageV4("Letisha", "flying planes"); }

Georgia Institute of Technology Walking through the Code Execution starts in the main method –Which creates a WebPageWriter object –And then calls the writeHomepageV4 method Passing in copies of the references to the string objects "Letisha" and "flying planes" The writeHomepageV4 method executes –With a name variable referring to "Letisha" and the interests variable referring to "flying planes". An object of class TempFinder is created –the method getTempFromNetwork is used to get the temperature from An object of the class SentenceGenerator is created –the method generateRandomSentence is used to return a random sentence as a String object

Georgia Institute of Technology Walking through the code (Continued) Execution continues in the try block –We try to create a BufferedWriter object using a FileWriter object created from a file with the passed in name and ".html" –The method writeStart is called –The method writeHead is called –The method writeBody is called With a string that includes the current temperature and a random sentence –The method writeEnd is called –We close the BufferedWriter to finish writing to the file If an exception occurs during the execution of any code in the try block then the catch block will execute –And the stack trace will be printed

Georgia Institute of Technology Exercise Write a class that gets some information from a Web page –Such as the top headline on –Or sport scores –Or stock values Create a homepage that includes that class to get the information and displays it in the homepage

Georgia Institute of Technology Databases Many Web sites use databases to store information –And then dynamically generate HTML pages from information in the database Based on user input –eBay, Amazon, Google, Delta, etc

Georgia Institute of Technology Why Use Databases? They are fast –Use indices to find information quickly Like finding a name in a phone book They can store lots of data –Google uses databases to answer search queries –Walmart has huge databases of products and sales They are standard –Use the same language to put data in and get it out Even from different databases (Access, Oracle, mySQL) They allow many people access to the data –Distributed access over network

Georgia Institute of Technology Storing Related Data Most databases are relational databases –They store related data in tables –The table on right shows an implied relationship between a person and a number (age) Mark43 Matt14 Sharquita30 Edgar42

Georgia Institute of Technology Summary You can read data from one Web page –And use it in another web page –Like Google News Databases are used to store large amounts of data –In tables with related data in the same row of the table –So that many people and programs can access the data