Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Applets Computer Science 101 Applets and CGI Scripts Look and Feel • An applet is a Java application that can run in a Web browser. • With some restrictions, an applet can have the same look, feel, and functionality of any Java application. • Applets run in a “protected” environment in the client's web browser, so that hackers can't write destructive programs (e.g., erase client's disk!) How Java Applications Are Run Inputs from me Anyfile.class Disk on my computer Java virtual machine Outputs to me How Java Applets Are Run Inputs from me The Applet HTML Tag General form: <APPLET CODE="Anyfile.class" WIDTH=anInt HEIGHT=anInt> Anyfile.class Disk on any computer Anyfile.html Java virtual machine Outputs to me Web browser WIDTH and HEIGHT give the number of pixels in the dimensions of the applet’s “window” on the page Example: <APPLET CODE="CircleAreaAndRadius.class" WIDTH=300 HEIGHT=150> An HTML code asks the browser to load a Java program HTML Code for the Web Page Changes to a Java Program • The program extends GBApplet instead of GBFrame • The main method is omitted • The size of the window is specified in the HTML file, not in the Java file From Application to Applet From Application to Applet import javax.swing.*; import BreezySwing.*; import javax.swing.*; import BreezySwing.*; public class CircleAreaAndRadius extends GBFrame{ public class CircleAreaAndRadius extends GBApplet{ // Set up window objects // Set up window objects // Declare data variables // Declare data variables // Implement the buttonClicked method // Implement the buttonClicked method public static void main(String[] args){ CircleAreaAndRadius theGUI = new CircleAreaAndRadius(); theGUI.setSize (300, 150); theGUI.setVisible(true); } // Main method goes away } } Some W&L Science Applets to Try http://www.cs.wlu.edu/chatbots/george http://www.cs.wlu.edu/chatbots/robert Interactive chat with “George Washington” & “Robert E. Lee” http://chaos.wlu.edu/106/programs.html The Wonderful World of Chaos http://www.cs.wlu.edu/~levy/bw Evolve beautiful fractal images CGI Scripts: A Different Approach to Interaction • Recall client/server model from last time: Server stores and “serves up” complete web pages to client, over network. • What if we want to change the appearance of the pages dynamically, based on user input? • Java applets may be more powerful than we need, and too much work to program. • Solution: a program that “automagically” generates the right HTML code for us... CGI Scripts: A Different Approach to Web Interaction • CGI: Common Gateway Interface – another protocol; specifies how pages are presented over the Web • Script – any “lightweight” program that is relatively small and solves a particular, uninteresting problem quickly. • E-commerce, Search Engines: the “killer apps” for CGI scripts CGI Scripts: Client/Server View <HTML> _____ _____ </HTML> Network connection Client’s browser CGI Script Server’s disk CGI Scripts: Specifying Parameters • Need, e.g., to tell Annie the subject you want to search for. • Look at top of browser: http://annie.wlu.edu/search/X?SEARCH=robots&l=&m=&b=&p=&Da=&Db=&SORT= parameters • Then Annie generates a web page containing links to these books. Popular CGI Scripting Languages • Perl : The “duct tape” of the Internet • Python: Object-oriented, pseudocode-like language • C: Low-level language for old-school hackers • Javascript: Lightweight Java, used mainly (?) for annoying pop-ups • JSP, ASP – commerical packages that simplify script-writing.