Chapter 18 Networking Client/Server Communications

Slides:



Advertisements
Similar presentations
What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
Advertisements

4.01 How Web Pages Work.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
1 L54 Networking (3). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
The Internet Useful Definitions and Concepts About the Internet.
1 L52 Networking (1). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
OCT1 Principles From Chapter One of “Distributed Systems Concepts and Design”
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L24 (Chapter 25) Networking.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L23 (Chapter 25) Networking.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L22 (Chapter 25) Networking.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
Topics in this presentation: The Web and how it works Difference between Web pages and web sites Web browsers and Web servers HTML purpose and structure.
WWW and Internet The Internet Creation of the Web Languages for document description Active web pages.
COMPUTER TERMS PART 1. COOKIE A cookie is a small amount of data generated by a website and saved by your web browser. Its purpose is to remember information.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
ASHIMA KALRA IMPORTANT TERMS.  WWW WWW  URL URL  HTTP PROTOCOL HTTP PROTOCOL  PROXIES PROXIES.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
ITIS 1210 Introduction to Web-Based Information Systems Chapter 4. Understanding the Internet’s Software Structure.
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
Chapter 4 Networking and the Internet. © 2005 Pearson Addison-Wesley. All rights reserved 4-2 Chapter 4: Networking and the Internet 4.1 Network Fundamentals.
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
Chapter 18 Networking F Client/Server Communications F Simple Client/Server Applications F Serve Multiple Clients F Create Applet Clients F Send and Retrieve.
1 Welcome to CSC 301 Web Programming Charles Frank.
CS 7: Introduction to Computer Programming Java and the Internet Sections ,2.1.
1 Chapter 28 Networking. 2 Objectives F To comprehend socket-based communication in Java (§28.2). F To understand client/server computing (§28.2). F To.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
Chapter 16: Networking F Client/Server Communications F Serving Multiple Clients F Applet Clients F Viewing HTML Pages F Retrieving Files from Web Servers.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
Computer Network Architecture Lecture 6: OSI Model Layers Examples 1 20/12/2012.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 33 Networking.
The Echo Server Problem. Contents  Basic Networking Concepts  The Echo Server Problem.
4.01 How Web Pages Work.
4.01 How Web Pages Work.
CX Introduction to Web Programming
Web Programming Language
4.01 How Web Pages Work.
Tonga Institute of Higher Education IT 141: Information Systems
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
WWW and HTTP King Fahd University of Petroleum & Minerals
Technologies and Applications
Affinity Depending on the application and client requirements of your Network Load Balancing cluster, you can be required to select an Affinity setting.
CISC103 Web Development Basics: Web site:
Warm Handshake with Websites, Servers and Web Servers:
What is RMI? Remote Method Invocation
Some bits on how it works
Some Common Terms The Internet is a network of computers spanning the globe. It is also called the World Wide Web. World Wide Web It is a collection of.
Distributed Computing, M. L. Liu
Distributed Computing, M. L. Liu
Computer Communication & Networks
Chapter 27 WWW and HTTP.
Application layer Lecture 7.
Tonga Institute of Higher Education IT 141: Information Systems
Chapter 40 Remote Method Invocation
Tonga Institute of Higher Education IT 141: Information Systems
HyperText Transfer Protocol
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
Chapter 42 Web Services.
4.01 How Web Pages Work.
Uniform Resource Locator: URL
4.01 How Web Pages Work.
The Internet and Electronic mail
Q/ Compare between HTTP & HTTPS? HTTP HTTPS
Presentation transcript:

Chapter 18 Networking Client/Server Communications Simple Client/Server Applications Serve Multiple Clients Create Applet Clients Send and Retrieve Objects on the Network The URL Class Retrieve Files from the Network Retrieve Files from Web Servers View HTML Pages

Client/Server Communications

Coding Client and Server

Example 18.1 A Client/Server Example Objective: Write a client to send data to a server. The server receives the data, uses it to produce a result, and then sends the result back to the client. The client displays the result on the console. In this example, the data sent from the client is the radius of a circle, and the result produced by the server is the area of the circle.

Example 18.1, cont. Server Code Client Code Run Note: The Run button will start the server first, then start the client. Press Ctrl+C to close the window.

Example 18.2 Serving Multiple Clients Server for Multiple Clients Run Note: The Run button will start the server first, then starts two clients. Press Ctrl+C to close the window.

Applet Clients Due to security constraints, applets can only connect to the host from which they were loaded. Therefore, the HTML file must be located on the machine on which the server is running.

Example 18.3 Creating Applet Clients Objective: shows how to use an applet to register students. The client collects and sends registration information to the server. The server appends the information to a data file using a random access file. Server Code Client Code Run Note: The Run button will start the server first, then the client applet.

Example 18.4 Passing Objects in Network Programs Objective: This example rewrites Example 18.3, using object streams on the socket. Instead of passing name, street, state, and zips separately, this program passes the student object as a whole object. Server Code Client Code Run Note: The Run button will start the server first, then the client applet.

Viewing HTML Pages Given the URL of the page, a Web browser can view an HTML page—for example, http://www.sun.com. HTTP (Hypertext Transfer Protocol) is the common standard used for communication between a Web server and the Internet. You can open a URL and view a Web page in a Java applet. A URL is a description of a resource location on the Internet. Java provides a class—java.net.URL—to manipulate URLs.

Creating a URL Instance The following statement creates a Java URL object: try { URL location = new URL("http://www.sun.com"); } catch(MalformedURLException ex) { } ViewWebPage You have to run this program from a JDK 1.2-enabled Web browser. This applet cannot run using the Applet Viewer utility.

Example 18.5 Viewing HTML Pages from Java The following figure shows the process by which an applet/application reads the files on the Web server:

Example 18.6 Retrieving Remote Files Objective: The example is similar to Example 17.4. Rather than reading the file from the local system, this example reads the file from a Web server. ViewRemoteFile Run

Deploy Files on a Web Server You need to place three files on the Web server: ViewRemoteFile.class ViewRemoteFile.html in.dat For convenience, place them in one directory.

Example 18.7 Creating a Web Browser Viewing HTML Files Using the JEditorPane. JEditorPane can be used to display HTML files. WebBrowser Run Applet Viewer

Distributed TicTacToe Game TicTacToeServer Run Note: The Run button will start the server first, then two clients. TicTacToeClient

Distributed TicTacToe, cont.

Distributed TicTacToe Game