Uniform Resource Locator: URL

Slides:



Advertisements
Similar presentations
Programming TCP Clients Version InetAddress Class An IP address identifies uniquely a host in the internet, which consists of 4 numbers (1 byte.
Advertisements

Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
Prepared By E. Musa Alyaman1 URLs, InetAddresses, and URLConnections Chapter 9.
Web development  World Wide Web (web) is the Internet system for hypertext linking.  A hypertext document (web page) is an online document. It contains.
Programming TCP Clients. InetAddress Class An IP address identifies uniquely a host in the internet, which consists of 4 numbers (1 byte each one) in.
1 Java Networking CS , Spring 2008/9. 2 Today’s Menu Networking Basics  TCP, UDP, Ports, DNS, Client-Server Model TCP/IP in Java Sockets URL 
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L24 (Chapter 25) Networking.
28-Jun-15 Basic Protocols. 2 Sockets Sockets, or ports, are a very low level software construct that allows computers to talk to one another When you.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
Programming TCP Clients Version InetAddress Class An IP address identifies uniquely a host in the internet, which consists of 4 numbers (1 byte.
13-Jul-15 Sockets and URLs. 2 Sockets A socket is a low-level software device for connecting two computers together Sockets can also be used to connect.
Creating your website Using Plain HTML. What is HTML? ► Web pages are authored in HyperText Markup Language (HTML) ► Plain text is marked up with tags,
15-Jul-15 Basic Protocols. 2 Sockets Sockets, or ports, are a very low level software construct that allows computers to talk to one another When you.
JAVA - Network DUT Info - Option ISI (C) Philippe Roose , 2005.
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.
Computer Networks  Network - A system of computers interconnected in order to share information.  Data transmission - consists of sending and receiving.
CSE 143 Lecture 21 I/O Streams; Exceptions; Inheritance read 9.3, 6.4 slides created by Marty Stepp
Appendix F: Network Programming in Java ©SoftMoore ConsultingSlide 1.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
Application Protocols: HTTP CSNB534 Semester 2, 2007/2008 Asma Shakil.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
Import java.net.*; import java.io.*; public class LowPortScanner { public static void main(String[] args) { String host = "localhost"; if (args.length.
DBI Representation and Management of Data on the Internet.
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 Streams Files are a computer’s long term memory Need ability for programs to –get information from files –copy information from program variables to.
Servlet Communication Other Servlets, HTML pages, objects shared among servlets on same server Servlets on another server with HTTP request of the other.
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.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
The Web and Web Services Jim Graham NR 621 Spring 2009.
Jsp (Java Server Page) Is a server side program.
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.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 12: Accessing the Web URL (Uniform Resource Locator) class Applet methods –for audio clips –for images –context interface.
Introduction to Applets Chapter 21. Applets An applet is a Java application that is intended to be invoked and executed through a Web browser. Click Here.
Java Programming II Java Network (I) Java Programming II.
1 Lecture 9: Network programming. 2 Manipulating URLs URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on.
URL Programming Mimi Opkins CECS277. What is a URL?  URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on.
Building Java Programs Bonus Slides I/O Streams; Exceptions; Inheritance Copyright (c) Pearson All rights reserved.
Web Page Design The Basics. The Web Page A document (file) created using the HTML scripting language. A document (file) created using the HTML scripting.
Glencoe Introduction to Multimedia Chapter 2 Multimedia Online 1 Internet A huge network that connects computers all over the world. Show Definition.
4.01 How Web Pages Work.
Secure Sockets SSL (Secure Sockets Layer) is a standard security technology for establishing an encrypted link between a server and a client—typically.
4.01 How Web Pages Work.
CSE 143 Lecture 22 I/O Streams; Exceptions; Inheritance read 9.3, 6.4
Network Programming Introduction
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Some bits on how it works
Chapter 18 Networking Client/Server Communications
Network Programming Introduction
Sockets and URLs 17-Sep-18.
Sockets and URLs 13-Nov-18.
Clients and Servers 19-Nov-18.
Basic Protocols 24-Nov-18.
URL in Java C343 Lab (Week 13).
Clients and Servers 1-Dec-18.
Networking.
Sockets and URLs 3-Dec-18.
HTTP and Sockets Lecture 6
Lecture 25: I/O Streams; Exceptions; Inheritance
Basic Protocols 19-Feb-19.
CSE 143 Lecture 25 I/O Streams; Exceptions; Inheritance read 9.3, 6.4
Unit-3.
4.01 How Web Pages Work.
Information Retrieval and Web Design
Programming TCP Clients
Clients and Servers 19-Jul-19.
Clients and Servers 13-Sep-19.
Presentation transcript:

Uniform Resource Locator: URL Hierarchy of Classes Methods of the Class Examples of Using the Class

Hierarchy of Classes

URL Class Class URL is a description of a resource location on the Internet. Complete URL: http://www.cs.joensuu.fi:1547/~john/pub/index.html -- protocol : http:// -- host : www.cs.joensuu.fi -- port : 1547 -- path : ~smith/pub/index.html Java provides a class—java.net.URL—to manipulate URLs.

Methods of URL Class Main methods of the class URL: URL(String url): create an object using the string parameter (exception MalformedURLException). URL(String, String, String): protocol, host, path of the resource. String toString(): return the URL as a strings. String getHost(): return the name of the host linked to this URL. String getProtocol(): return le protocol of this URL. String getPort(): return the number of the associate port.

Methods of URL Class InputStream openStream(): realize the connection to the URL previously instantiated. An InputStream object is returned and permits to retrieve information specified into the URL. If the connection fails, the exception IOException is raised.

Creating a URL Instance The following statement creates a Java URL object: String str = "http://www.sun.com”; try { URL location = new URL(str); } catch(MalformedURLException ex) { }

Example 18.6: Retrieving Remote Files Rather than reading the file from the local system, this example reads the file from a Web server. private void showFile() { URL url = null; try { url = new URL(urlString); InputStream is = url.openStream(); infile = new BufferedReader( new InputStreamReader(is)); } catch (FileNotFoundException e) { ... } catch (IOException e) { ... }

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.

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.5 Viewing HTML Pages from Java The following figure shows the process by which an applet/application reads the files on the Web server: