5 URLs and URIs

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What are ways that the URI class differs from the URL class? A The URI class is purely about identification of resources and parsing of URIs B The URI class is more conformant to the relevant specifications than the URL class C A URI object can represent a relative URI. The URL class absolutizes all URIs before storing them D A URL object can represent a relative URI. The URI class absolutizes all URIs before storing them

A The URI class is purely about identification of resources and parsing of URIs B The URI class is more conformant to the relevant specifications than the URL class C A URI object can represent a relative URI. The URL class absolutizes all URIs before storing them

Parts of a URI:

A URI reference has up to three parts: a scheme, a scheme-specific part, and a fragment identifier.

Primary difference between URL and URI function?

A URL object is a representation of an application layer protocol for network retrieval, whereas a URI object is purely for string parsing and manipulation.

What is true about using the GET method? A You need to know the combination of names and values the program expects to receive B You only need to know the combination of names C You only need to know the values the program expects to receive D The GET method can only accept one name and value the program expects to receive

A You need to know the combination of names and values the program expects to receive

What are methods inherited from the Authenticator superclass? A getRequestingPort() B getRequestingProtocol() C getRequestingHost() D getRequestingName()

A getRequestingPort() B getRequestingProtocol() C getRequestingHost()

URLEncoder.encode() returns a copy of the input string with a these changes:

Any nonalphanumeric characters are converted into % sequences (except the space, underscore, hyphen, period, and asterisk characters). It also encodes all non-ASCII characters. The space is converted into a plus sign. It also converts tildes, single quotes, exclamation points, and parentheses to percent escapes, even though they don't absolutely have to be.

The ___________ class can be used to provide a username and password for sites that protect themselves using HTTP authentication.

Authenticator *Since Authenticator is an abstract class, you must subclass it.

What is this line of code performing? URL u - new URL("http://www.abc.com/""); A Constructing a URL object from a relative URL B Constructing a URL object from a string C Redirecting to a URL object from a relative URL D Redirecting to a URL object from a string

B Constructing a URL object from a string

Where is the ACTION attribute of the FORM element placed? A The action cannot be defined B After the query string C Precedes the query string D The Action attribute cannot be used with a URL

C Precedes the query string

What is the query portion of http://www.powells.com/cgi-bin/biblio?inkey=62-1565928709-0? A www.powells.com B /cgi-bin/biblio C inkey=62-1565928709-0 D http://

C inkey=62-1565928709-0

What is this line of code performing? URL u1 = new URL(""http://www.abc.com/javafaq/index.html""); URL u2 = new URL (u1, ""mailinglists.html""); A Builds an relative URL from a relative URL and a base URL B Builds an relative URL from a base URL C Builds an absolute URL from a base URL D Builds an absolute URL from a relative URL and a base URL

D Builds an absolute URL from a relative URL and a base URL

Which is a constructor for the PasswordAuthentication class? A public PasswordAuthentication(String userName, String password) B public PasswordAuthentication(char[] userName, char[] password) C public PasswordAuthentication(char[] userName, String password) D public PasswordAuthentication(String userName, char[] password)

D public PasswordAuthentication(String userName, char[] password)

The three kinds of proxies:

HTTP SOCKS direct connections (no proxy at all) Each respectively represented by three constants in the Proxy.Type enum: Proxy.Type.HTTP Proxy.Type.SOCKS Proxy.Type.DIRECT

One of the biggest problems with using getContent()?

It's hard to predict what kind of object you'll get.

A lightweight component that allows the editing of a single line of text where the view indicates something was typed, but does not show the original characters:

JPasswordField

Each running virtual machine has a single java.net._____________ object it uses to locate the proxy server for different connections.

ProxySelector The default ProxySelector merely inspects the various system properties and the URL's protocol to decide how to connect to different hosts.

Difference between the getFile() method and the getPath() method

The getFile() method returns a String that contains the path portion of a URL- Everything from the first slash (/) after the hostname until the character preceding the # sign that begins a fragment identifier is considered to be part of the file. If the URL does not have a file part, Java sets the file to the empty The getPath() method is a near synonym for getFile(); that is, it returns a String containing the path and file portion of a URL. However, unlike getFile(), it does not include the query string in the String it returns, just the path.

What does the getProtocol() method do?

The getProtocol() method returns a String containing the scheme of the URL (e.g., "http", "https", or "file").

What does the getRef() method do?

The getRef() method returns the fragment identifier part of the URL.

What is a URIs "scheme"?

The scheme is the URI's protocol, such as http, urn, tel, and so forth.

T/F The "equals()" method compares the DNS resolution of URLs compared

True

A ____________________ represents an open connection to a network resource.

URLConnection

_______________ class has a static __________ method that decodes strings encoded in x-www-form-url-encoded format. That is, it converts all plus signs to spaces and all percent escapes to their corresponding character.

URLDecoder, decode()

Relative URL

URLs that aren't complete but inherit pieces from their parent are called relative URLs

URI

Uniform Resource Identifier A string of characters in a particular syntax that identifies a resource *The syntax of generic URIs and absolute URI references was first defined in Request for Comments (RFC) 2396, published in August 1998,[3] and finalized in RFC 3986, published in January 2005.

URL

Uniform Resource Locator A URL is a URI that, as well as identifying a resource, provides a specific network location for the resource that a client can use to retrieve a representation of that resource.

URN

Uniform Resource Name

The _____________ method retrieves the data referenced by the URL and tries to make it into some type of object.

getContent() If the URL refers to some kind of text such as an ASCII or HTML file, the object returned is usually some sort of InputStream. If the URL refers to an image such as a GIF or a JPEG file, getContent() usually returns a java.awt.ImageProducer.

This method returns the username and password (if present otherwise null) from a URL:

getUserInfo()

The ______________ method returns true if the URI is absolute, false if it's relative.

isAbsolute() A URI that has a scheme is an absolute URI. A URI without a scheme is relative.

The _______________ method returns false if the URI is hierarchical, true if it's not hierarchical—that is, if it's opaque.

isOpaque() For example, in a tel URL, the scheme-specific part has the syntax of a telephone number. However, in many useful URIs, including the very common file and http URLs, the scheme-specific part has a particular hierarchical format divided into an authority, a path, and a query string. The authority is further divided into user info, host, and port.

Java URL class:

java.net.URL

The __________________ method opens a socket to the specified URL and returns a URLConnection object.

openConnection()

The _____________ method connects to the resource referenced by the URL, performs any necessary handshaking between the client and the server, and returns an InputStream from which data can be read.

openStream() *The data you get from this InputStream is the raw (i.e., uninterpreted) content the URL references: ASCII if you're reading an ASCII text file, raw HTML if you're reading an HTML file, etc.

The syntax of a URL is:

protocol://userInfo@host:port/path?query#fragment - The userInfo is optional login information for the server - Together, the userInfo, host, and port constitute the authority - The query string provides additional arguments for the server - The fragment references a particular part of the remote resource. If the remote resource is HTML, the fragment identifier names an anchor in the HTML document. If the remote resource is XML, the fragment identifier is an XPointer

Describe the "fragment" portion of a URL

protocol://userInfo@host:port/path?query#fragment The fragment references a particular part of the remote resource. If the remote resource is HTML, the fragment identifier names an anchor in the HTML document. If the remote resource is XML, the fragment identifier is an XPointer

The __________ method creates a new URI object from the URI argument that is relative to the invoking URI. The argument is not changed.

relativize()

The ___________ method that checks whether two URLs point to the same resource.

sameFile()

URLs are composed of five pieces:

scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment] The scheme, also known as the protocol The authority (user, password, host, port) The path The query string The fragment identifier, also known as the section or ref

The ________________ method converts a URL object to a string that can be used in an HTML link or a web browser's Open URL dialog.

toExternalForm()

the _______________ method converts a URL object to an equivalent URI object.

toURI()

PasswordAuthentication is a very simple final class that supports two read-only properties:

username and password


Set pelajaran terkait

PA - Environmental Emergencies Guest Lecture - CM, 11/18

View Set

Musculoskeletal 1&2 WWCC Nursing

View Set

Endothermic and Exothermic Questions

View Set