CSC 551: Web Programming. Spring 2004



Similar documents
Java applets. SwIG Jing He

CSC 551: Web Programming. Fall 2001

1. Overview of the Java Language

Java in Education. Choosing appropriate tool for creating multimedia is the first step in multimedia design

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution

Contents. Java - An Introduction. Java Milestones. Java and its Evolution

An Overview of Java. overview-1

Mobile Application Languages XML, Java, J2ME and JavaCard Lesson 04 Java

SE 450 Object-Oriented Software Development. Requirements. Topics. Textbooks. Prerequisite: CSC 416

INTRODUCTION TO JAVA PROGRAMMING LANGUAGE

Chapter 1 Programming Languages for Web Applications

What Perl Programmers Should Know About Java

Evolution of the Major Programming Languages

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Crash Course in Java

CS 209 Programming in Java #1

Building Java Servlets with Oracle JDeveloper

Chapter 1 Java Program Design and Development

Java vs. Java Script

core. Volume I - Fundamentals Seventh Edition Sun Microsystems Press A Prentice Hall Title ULB Darmstadt

2 Introduction to Java. Introduction to Programming 1 1

Fundamentals of Java Programming

How To Write A Program For The Web In Java (Java)

Applets, RMI, JDBC Exam Review

CS506 Web Design and Development Solved Online Quiz No. 01

How To Use A Sas Server On A Java Computer Or A Java.Net Computer (Sas) On A Microsoft Microsoft Server (Sasa) On An Ipo (Sauge) Or A Microsas (Sask

Developing Embedded Software in Java Part 1: Technology and Architecture

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Chapter 27 Hypertext Transfer Protocol

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

If your organization is not already

Java and Java Virtual Machine Security

Risks with web programming technologies. Steve Branigan Lucent Technologies

Architecture Design For Web-based Application Systems. Instructor: Dr. Jerry Gao Class: CMPE296U

JAVA WEB START OVERVIEW

-8*6-DYD6HPLQDU 6HUYOHW$UFKLWHFWXUHV 5DLQHU+LVV$QGUHDV.DSS 6<6725$*

7 Why Use Perl for CGI?

Syllabus for CS 134 Java Programming

Lecture 1 Introduction to Android

Chapter 1 Introduction to Computers, Programs, and Java

Java History. Java History (cont'd)

Fig (1) (a) Server-side scripting with PHP. (b) Client-side scripting with JavaScript.

Version Overview. Business value

02 B The Java Virtual Machine

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

C# and Other Languages

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Chapter 13 Computer Programs and Programming Languages. Discovering Computers Your Interactive Guide to the Digital World

Sample copy. Introduction To WebLogic Server Property of Web 10.3 Age Solutions Inc.

Server-Side Web Development JSP. Today. Web Servers. Static HTML Directives. Actions Comments Tag Libraries Implicit Objects. Apache.

Elements of Advanced Java Programming

WEB PROGRAMMING DESKTOP INTERACTIVITY AND PROCESSING

The Basic Java Applet and JApplet

Java Crash Course Part I

Web Pages. Static Web Pages SHTML

Programming Languages

Overview. Java Programming Language. What is Java in a NutShell? Architecture of Java Applets

Web development... the server side (of the force)

LabVIEW Internet Toolkit User Guide

Glassfish, JAVA EE, Servlets, JSP, EJB

Agent Languages. Overview. Requirements. Java. Tcl/Tk. Telescript. Evaluation. Artificial Intelligence Intelligent Agents

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

Habanero Extreme Scale Software Research Project

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

To Java SE 8, and Beyond (Plan B)

Efficiency of Web Based SAX XML Distributed Processing

Chapter 1. Introduction to Computers, Programs, and Java

SmartArrays and Java Frequently Asked Questions

Java with Eclipse: Setup & Getting Started

Introduction to Object-Oriented Programming

Can You Trust Your JVM Diagnostic Tools?

Installing Java (Windows) and Writing your First Program

2. Accessing Databases via the Web

CatDV Pro Workgroup Serve r

Session 12 Evolving IT Architectures: From Mainframes to Client-Server to Network Computing

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

Clustering with Tomcat. Introduction. O'Reilly Network: Clustering with Tomcat. by Shyam Kumar Doddavula 07/17/2002

Titolo del paragrafo. Titolo del documento - Sottotitolo documento The Benefits of Pushing Real-Time Market Data via a Web Infrastructure

Installing Java. Table of contents

How To Write A Program In Java (Programming) On A Microsoft Macbook Or Ipad (For Pc) Or Ipa (For Mac) (For Microsoft) (Programmer) (Or Mac) Or Macbook (For

Pentesting Web Frameworks (preview of next year's SEC642 update)

Rich Internet Applications

Online Recruitment System 1. INTRODUCTION

Computer Networks. Lecture 7: Application layer: FTP and HTTP. Marcin Bieńkowski. Institute of Computer Science University of Wrocław

4.2 Understand Microsoft ASP.NET Web Application Development

In this chapter, we lay the foundation for all our further discussions. We start

1. Introduction 1.1 Methodology

TABLE OF CONTENTS...2 INTRODUCTION...3 APPLETS AND APPLICATIONS...3 JAVABEANS...4 EXCEPTION HANDLING...5 JAVA DATABASE CONNECTIVITY (JDBC)...

How To Test Your Web Site On Wapt On A Pc Or Mac Or Mac (Or Mac) On A Mac Or Ipad Or Ipa (Or Ipa) On Pc Or Ipam (Or Pc Or Pc) On An Ip

ATSBA: Advanced Technologies Supporting Business Areas. Programming with Java. 1 Overview and Introduction

What Is the Java TM 2 Platform, Enterprise Edition?

Specialized Android APP Development Program with Java (SAADPJ) Duration 2 months

IDL. Get the answers you need from your data. IDL

Apache Jakarta Tomcat

Webmail Using the Hush Encryption Engine

Transcription:

CSC 551: Web Programming Spring 2004 Java Overview Design goals & features platform independence, portable, secure, simple, object-oriented, Programming models applications vs. applets vs. servlets intro to applets libraries, comments, classes, inheritance applet tag in HTML applet parameters 1 Java Java was developed at Sun Microsystems, 1995 originally designed for small, embedded systems in electronic appliances initial attempts used C++, but frustration at limitations/pitfalls recall: C++ = C + OOP features the desire for backward compatibility led to the retention of many bad features desired features (from the Java white paper): simple object-oriented robust platform independent architecture neutral portable dynamic interpreted high-performance distributed multi-threaded secure note: these are desirable features for any modern language thus, Java has become very popular, especially when Internet related also, Sun distributes free compilers (JDK) and open source 2

Language features simple syntax is based on C++ (familiarity easier transition for programmers) removed many confusing and/or rarely-used features e.g., explicit pointers, operator overloading, automatic coercions added memory management (reference count/garbage collection hybrid) object-oriented OOP facilities similar C++, all methods are dynamically bound pure OOP everything is a class, no independent functions* robust lack of pointers and memory management avoids many headaches/errors libraries of useful, tested classes increases level of abstraction arrays & strings are ADTs, well-defined interfaces 3 Language features (cont.) platform independence want to be able to run Java code on multiple platforms neutrality is achieved by mixing compilation & interpretation 1. Java programs are translated into byte code by a Java compiler byte code is a generic machine code 2. byte code is then executed by an interpreter (Java Virtual Machine) must have a byte code interpreter for each hardware platform an Applet is a special form of Java application byte code is downloaded with page, JVM is embedded in browser architecture-neutral no implementation dependent features (e.g., size of primitive types is set) portable byte code will run on any version of the Java Virtual Machine (JVM) high-performance faster than traditional interpretation since byte code is "close" to native code still somewhat slower than a compiled language (e.g., C++) 4

Language features (cont.) distributed extensive libraries for coping with TCP/IP protocols like HTTP & FTP Java applications can access remote URL's the same as local files multi-threaded a thread is like a separate program, executing concurrently can write Java programs that deal with many tasks at once by defining multiple threads (same shared memory, but semi-independent execution) threads are important for multi-media, Web applications secure Java applications do not have direct access to memory locations memory accesses are virtual, mapped by JVM to physical locations downloaded applets cannot open, read, or write local files JVM also verifies authenticity of classes as they are loaded Sun claim: execution model enables virus-free*, tamper-free* systems 5 Java programming models Java applications are stand-alone programs must be compiled into Java byte code by Java compiler, then distributed executed by an interpreter (Java Virtual Machine) Java applets provide for client-side programming compiled into Java byte code, then downloaded as part of a Web page executed by the JVM embedded within the Web browser unlike JavaScript, Java is full-featured with extensive library support Java and its APIs have become industry standards the language definition is controlled by Sun, ensures compatibility Applications Programming Interfaces standardize the behavior of useful classes and libraries of routines Java servlets provide similar capabilities on the server-side alternative to CGI programs, more fully integrated into Web server 6

Java applets important point: Java applets & applications look different! if you want to define a stand-alone application, make an application requires public static void main function, similar to C++ main if you want to embed the code in a Web page, make an applet requires public void paint, public void init, can define dual-purpose programs, but tricky as with JavaScript, security is central when a Java applet is downloaded, the bytecode verifier of the JVM verifies to see if it contains bytecodes that open, read, write to local disk a Java applet can open a new window but they have Java logo to prevent them from being disguised as system window (e.g., to steal passwords) a Java applet is not allowed to connect back to other servers except the host this secure execution environment is called sand box model 7 First Java applet * This class displays "Hello world!" on the applet window. public class HelloWorld extends Applet g.drawstring("hello world!", 10, 10); // writes starting 10 pixels over & down libraries: Java provides extensive library support in the form of classes libraries are loaded using import (similar to #include in C++) java.awt: contains Abstract Window Toolkit (for GUI classes & routines) java.applet: contains the applet class definition comments: // and /* work the same as in C++ also have which denote documentation comments (can be used to generate docs) 8

First Java applet * This class displays "Hello world!" on the applet window. public class HelloWorld extends Applet g.drawstring("hello world!", 10, 10); // writes starting 10 pixels over & down class definitions in Java similar to C++ (but no semi-colon at end) can contain instance variables (data fields) & methods(member functions) precede class & method definitions with public to make available to all programs there are no stand-alone functions in Java* must be stored in a file of same name with.java extension e.g., HelloWorld.java 9 First Java applet * This class displays "Hello world!" on the applet window. public class HelloWorld extends Applet g.drawstring("hello world!", 10, 10); // writes starting 10 pixels over & down all applets inherit from the Applet class (in java.applet) default methods include: init(): called when page is loaded to create/initialize variables by default, does nothing paint(graphics g): called to draw (after init) or redraw (after being obscured) here, the paint method is overridden to display text on the applet window 10

Embedding an applet in HTML to include an applet in a Web page, use either APPLET tag (deprecated) CODE specifies applet name, HEIGHT and WIDTH specify window size text between the APPLET tags is displayed if unable to execute (e.g., Java not enabled) OBJECT tag preferred for HTML 4, but not universally supported <html> <!-- Dave Reed hello1.html 3/20/04 --> <head> <title>hello World Page</title> </head> <body> <p> <applet code="helloworld.class" height=100 width=100> You must use a Java-enabled browser to view this applet. </applet> </p> </body> </html> view page in browser 11 HTML & applets <html> <!-- Dave Reed hello2.html 3/20/04 --> <head> <title>hello World Page</title> </head> <body> <p> <div align="center"> <table border=1> <tr><td> <applet code="helloworld.class" height=200 width=200> You must use a Java-enabled browser to view this applet. </applet> an applet can be embedded within HTML elements just like any other element useful for formatting and layout </td></tr> </table> </div> </p> </body> </html> view page in browser 12

Parameters in HTML <html> <!-- Dave Reed hello3.html 3/20/04 --> <head> <title>hello World Page</title> </head> <body> <p> <div align="center"> <table border=1> <tr><td> <applet code="helloworld1.class" height=35 width=300> <param name="name" value="chris"> <param name="age" value=20> You must use a Java-enabled browser to view this applet. </applet> </td></tr> </table> </div> </p> can specify parameters to the APPLET when it is embedded in HTML each parameter must have its own PARAM tag inside the APPLET element specifies parameter name and value </body> </html> view page in browser 13 Applet parameters * This class displays a message based on parameters. public class HelloWorld1 extends Applet String username = getparameter("name"); int userage = Integer.parseInt(getParameter("age")); String message1 = "Hello " + username + "."; String message2 = "On your next birthday, you will be " + (userage+1) + " years old."; g.drawstring(message1, 10, 10); g.drawstring(message2, 10, 30); can access parameters passed in from the HTML document getparameter accesses the value of the parameter (must know its name) if the parameter represents a number, must parseint or parsefloat 14