1. Preface

1.

Java4510: Preface to INEW 2338

2. Network Programming

. Java4610-Preface

. Java4620: General Information

. Java4620r-Review

. Java4630: The InetAddress Class

. Java4630r-Review

. Java4640: The URL Class and the URLEncoder Class . Java4640r-Review

. Java4650: The URLConnection Class

. Java4650r-Review

10. 11. 12.

Java4655: A Rendering Web Browser Java4660: Sockets Java4660r-Review

3. Search Engines

1. 2:

Java4585: Getting Started with Search Engines Java4590r-Review for search engines

4. Servlets

1

OOOAN DU BW N

—_

. Java4530: Getting Started with Servlets

. Java4530r-Review

. Java4535: Introduction to Servlet Code

. Java4535r-Review

. Java4550: Session Tracking using Hidden Fields

. Java4550r-Review

. Java4560: Session Tracking using URL Rewriting

. Java4570: Session Tracking using Cookies

. Java4570r-Review

. Java4580: Session Tracking using the Session Tracking

API

. Java4580r-Review

5. JSON

a POoOoWOON aU BRWN RP

—_— & WW

. Json0195: Preface to JSON

. Json0200: The What and Why of JSON

. Json0200R: Review

. Json0205: Getting Started

. Json0205R: Review

. Json0210: Structure of the json-simple Java Library . Json0210R: Review

. Json0215: Encoding JSON Strings

. Json0215R: Review

. Json0220: Decoding JSON Strings

. Json0220R: Review

12. . Json0225R: Review

. Json0230: Decoding JSON Arrays 15.

Json0225: Encoding JSON Arrays

Json0O230R: Review

6. Frameworks

1,

Java4710: INEW 2338 - Java EE 7 and Frameworks

Java4510: Preface to INEW 2338 This is a preface to the INEW2338 material.

Revised: Thu Jun 02 14:40:19 CDT 2016 This page is included in the following Books:

e INEW2338 - Advanced Java Programming ¢ Object-Oriented Programming_(QOP) with Java

Table of Contents

e Welcome

e Programming Oldies but Goodies ¢ Downloads

e Miscellaneous

Welcome

Welcome to the course material for INEW2338 - Advanced Java Programming , which I teach at Austin Community College in Austin, TX.

Information about the course The college website for this course is: http://www.austincc.edu/baldwin/

The prerequisite for the course is ITSE2317 - Java Programming (Intermediate) or department approval.

Each semester, the course covers three major topics :

e Network Programming e Search Engines OR Servlets OR JSON e Java EE and Frameworks

Note:

Note: Although only one of the topics Search Engines , Servlets , or JSON is covered in the course in any particular semester, all three are important. The course material in the Blackboard course management program will indicate which topic is covered in the current semester.

Students are encouraged to study all three topics for their own educational purposes in order to enhance their prospects of landing a job as a Java programmer.

Programming Oldies but Goodies

While much of the material required to succeed in this course is contained in the modules in this book, a large amount of relevant material is also contained in the collection titled Programming Oldies But Goodies , which is a work in process. The material in that collection has not yet been converted to the cnxml format required by OpenStax. Instead, the material in that collection is still in its original html format.

You would do well to familiarize yourself with that material as well.

Downloads

I encourage you to take advantage of the download options that OpenStax has to offer in order to customize this material for use in your organized courses or for personal self study.

Miscellaneous

This section contains a variety of miscellaneous information.

Note: Housekeeping material

e Module name: Java4510: Preface to INEW 2338 e File: Java4510.htm

e Published: 12/17/13

Note: Disclaimers:

Financial : Although the Connexions site makes it possible for you to download a PDF file for this module at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should be aware that some of the HTML elements in this module may not translate well into PDF.

I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module. In the past, unknown individuals have copied my modules from OpenStax, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. I neither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please be aware that it is a copy of a module that is freely available on OpenStax and that it was made and published without my prior knowledge.

Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.

-end-

Java4610-Preface This module serves as the preface to a sub-collection of modules on network programming.

Table of Contents e Discussion

e What's next? e Miscellaneous

Discussion

This module serves as the preface to a sub-collection of modules on network programming. The modules in this sub-collection are designed for teaching INEW 2338 Advanced Java (Web) at Austin Community College in Austin, TX.

What's next? The next module is titled Java4620: General Information .

As you might surmise from the title, it deals with such topics as communication protocols, clients, servers, IP, TCP, ports, etc.

Miscellaneous

This section contains a variety of miscellaneous information.

Note: Housekeeping material

e Module name: Java4610-Preface e File: Java4610.htm

Published: 03/02/14

Revised 12/26/14

Note: Disclaimers:

Financial : Although the Connexions site makes it possible for you to download a PDF file for this module at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should be aware that some of the HTML elements in this module may not translate well into PDF.

I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module. In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. I neither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please be aware that it is a copy of a module that is freely available on cnx.org and that it was made and published without my prior knowledge.

Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.

-end-

Java4620: General Information The purpose of this module is to introduce the student to various aspects of network programming that will be incorporated into future modules.

Table of Contents

e Preface e Introduction e Background Information

Communication Protocol Network Layers

Clients and Servers

IP, TCP, and, UDP

o Oo 0 0

IP_ Addresses

Domain Names

What is Your IP Address? Ports

Firewalls

Proxy Servers

Standards and Protocols URL

oOo 000 0 0 0

e Socket Classes and the URL Class

o Socket Programming o URL Programming

e A local area network ¢ The operating system e What's Next?

e Miscellaneous

Preface

This module is one in a collection of modules designed for teaching INEW 2338 Advanced Java (Web) at Austin Community College in Austin, TX. More specifically, it is one in a sub-collection of modules designed for teaching network programming in that course. The purpose of this module is to introduce the student to various aspects of network programming that will be incorporated into future modules.

Introduction

One of the Java books on my bookshelf makes the following analogy (or one very similar) . Just because you may know how to speak conversational French doesn't mean that you know how to interpret an autopsy report written in French. In order to interpret the autopsy report, you must also know a good deal about the meaning of the medical terms used in such reports.

A similar situation exist for networking. It isn't very difficult to learn how to use the Java programming language to implement some network operations. However, in order to achieve depth in this area, you probably also need to know something about the many other technical aspects of networking.

This is not a new field, and many good books have been written on the technical details of networking. you are referred to one or more of those books to gain an in-depth knowledge of networking. In particular, I would refer you to Java Network Programming by Elliotte Rusty Harold.

In addition there are many other books that contain excellent sections on network programming. I would recommend that you take a look at the following:

e Exploring Java by Patrick Niemeyer and Joshua Peck e Just Java 1.1 and Beyond by Peter van der Linden

e Java Primer Plus by Tyma, Torok, and Downing

e Java How to Program by Deitel and Deitel

These books have been around for a long time, so you should be able to find a used copy online for a reasonable price.

For the most part, this and the next few modules will be restricted to how you can use the programming capabilities of Java to write and execute network programs and won't attempt to go into overall network programming in depth. However, a minimal amount of background information will be required, so we will attempt to provide that background in this module. Subsequent modules will use this background along with the network programming capabilities of Java to write some simple, but interesting networking programs.

Background Information

For our purposes, a network is a group of computers and other devices that are connected in some fashion for the purpose of exchanging data.

Each of the devices on the network can be thought of as a node , and each node has a unique address. The manner in which addresses are assigned will vary from one type of network to another, but in all cases, the address of each device must be unique so as to distinguish it from the other devices.

Addresses are numeric quantities that are easy for computers to work with, but are not easy for humans to remember. Therefore, some networks also provide names that humans can more easily remember than numbers.

Modern networks transfer data using a concept known as packet switching . This means that the data are encapsulated into packets that are transferred from the source to the destination. It is necessary to extract the data from one or more packets at the destination and use it to reconstruct the original message.

Communication Protocol

In order for two or more computers connected to a network to be able to exchange data in an orderly manner, they must adhere to a mutually

acceptable communication protocol. The protocol defines the rules by which they communicate.

Teaching your children to say please and thank you involves teaching them something about a protocol. If they occasionally forget to say please, however, they will probably get the cookie anyway.

If a computer protocol requires the participating computers to say please, and they forget to say please, they probably won't get the cookie.

There are many protocols available. For example, the HTTP protocol defines how web browsers and servers communicate and the SMTP protocol defines how email is transferred (we will write programs that implement part of the HTTP protocol) .

Note here that I have been discussing application protocols that operate at the surface level. We will also be making mention of lower-level protocols that operate below the application level. Fortunately, as high-level Java programmers, we don't have to be too concerned about the lower-level protocols. We'll let the systems people worry about them.

Network Layers

Networks are logically separated into layers ranging from the Application Layer at the top to the Physical Layer at the bottom. The technical details of network layering are beyond the scope of this module. Fortunately, you will be able to write useful network programs using Java without understanding the details of network layering.

The Application Layer is the layer that delivers data to the user. The layers below that are involved with getting data from the Application Layer at one end of the conversation to the Application Layer at the other end. For the most part, we will be concerned only with the Application Layer .

Clients and Servers

In these modules, we will be concerned with networked communications that involve client computers and a server computers. How do we know which is which?

For the purposes of our studies, it will be sufficient to say that the client always initiates the conversation, and the server waits and listens for a client to initiate a conversation.

IP, TCP, and UDP We need to know something about the following acronyms:

e IP e TCP e UDP

IP

IP , which stands for Internet Protocol , is the protocol that will be involved below the Application Layer to move our data between a client and a server. Beyond knowing that it exists, we probably don't need to concern ourselves with the fact that IP is being used

In fact, in some situations, some other protocol could be used to move our data between a client and a server. As long as it works, we really don't care too much.

In a nutshell, IP is a network protocol that moves packets of data from a source to a destination. As the name implies, this is the protocol normally used on the Internet.

TCP

It is sometimes important to be able to have confidence that all packets that make up a message atrive at the destination undamaged and in proper order.

The Transmission Control Protocol (‘TCP ) was added to IP to give each end of a connection the ability to acknowledge receipt of IP packets and to request retransmission of corrupted or lost packets. Also TCP makes it possible to put the packets back together at the destination in the same order that they were sent.

Therefore, you will often hear people using both acronyms in the same breath, as in TCP/IP . The two work together to provide a reliable method of encapsulating a message into data packets, sending the packets to a destination, and reconstructing the message from the packets at the destination.

UDP

Sometimes it may not be critically important that all the packets arrive at the destination or that they arrive in the proper order. Further, sometimes, you may not want to incur the time delays and overhead cost associated with those guarantees.

For example, if one computer is sending date and time information to another computer every 100 milliseconds, and the data in the packets is displayed on a digital clock as it is received, you might prefer that each packet make the trip as quickly as possible even if that means that occasionally a packet will be lost or damaged.

The User Datagram Protocol ( UDP) is available to support this type of operation. UDP is often referred to as an unreliable protocol because there is no guarantee that a series of packets will arrive in the right order, or that they will arrive at all.

As Java programmers, we have the choice of TCP or UDP, and we need to know enough about the characteristics of each to be able to make informed

choices between them.

IP Addresses

We don't really need to know very much about IP to be able to use it, but we do need to know about the addressing scheme used in IP .

Every computer attached to an IP network has a unique address, typically consisting of four bytes or 32 bits ( JPv4_) .

Thirty-two bits are sufficient to define a large number of unique addresses, but the manner in which addresses are allocated is wasteful, and many of the addresses that have been allocated are not being used.

Efforts are underway to expand the number of possible unique addresses to a much larger number. The planned number is the number of unique addresses that can be represented with a 128-bit address. The new scheme is known as [Pv6.

For human consumption, we usually convert the value of each of the bytes to an unsigned decimal value and display them connected by periods to make them easier to remember. For example, as near as I can tell, as of this writing, the IP address of www.austincc.edu (the college where I teach) is 206.77.150.222 .

Domain Names What do I mean by www.austincc.edu ?

Even though we can do some tricks to make the numeric IP addresses easier to remember, humans don't do a very good job of remembering long strings of numbers. Humans remember words and names better. Therefore, most IP addresses have a corresponding name known as a domain name . The domain name for the IP address 206.77.150.222 is www.austincc.edu .

The Domain Name System (DNS) was developed to translate between IP addresses and domain names. Whenever you log your browser onto the internet and attempt to connect to a server using its domain name, the browser first communicates with a DNS server to learn the corresponding numeric IP address. The numeric IP address (and not the domain name) is encapsulated into the data packets and used by the internet protocol to route those packets from the source to the destination.

(You should also be able to enter 206.77.150.222 into the address field of your browser and access the college where I teach.)

We will learn how to use the Java InetAddress class to find the domain name corresponding to an IP address, and to find the IP address corresponding to a domain name.

What is Your IP Address? Do you have an IP address and a domain name ?

If (like me) you use a commercial Internet Service Provider (ISP) for your Internet service at home, you probably don't have a fixed IP address or a fixed domain name . Rather, the ISP has a block of IP addresses reserved. When you subscribe to the ISP, the ISP temporarily assigns an IP address to you. That IP address may or may not change over time, but probably will change unless you pay the extra fee for a fixed IP address.

On the other hand, I currently pay for server space from a company in North Carolina under the domain name www.dickbaldwin.com . My domain has an IP address of 98.129.229.162 . For as long as I continue to pay the bill, that domain name and that IP address will be assigned to me for use as my personal website.

I suppose that the company could change the IP address at some point provided that they make certain that all of the domain name servers get updated to reflect the new IP address that corresponds to the domain name.

Ports

Each server computer that you may connect to will be logically organized into ports . These are not physical ports in the sense of the VGA or HDMI port on the back of your computer. Rather, they are simply logical sub- addresses which you provide to the operating system on the server so that the operating system can cause the appropriate server software to "answer the call." We will write a simple server software package that will service several different ports on independent threads in a future module.

One of the Java books on my bookshelf refers to the IP address as being analogous to the telephone number of a company and the port to be analogous to the employee's telephone extension within that company. (At least that is how telephone systems in companies were organized when I was working in industry.)

Theoretically, there are 65,535 available ports. Port numbers between 1 and 1023 are predefined to be used for certain standard services. For example, if you want to connect with server software that communicates using the HTTP protocol, you would normally connect to port 80 on the server of interest.

Similarly, if you want to connect to a port that will tell you the time, you should connect to port 13, assuming that you can find a server somewhere that is willing to support port 13. If you want to connect to a port that will simply echo whatever you send to it (usually for test purposes) , you should connect to port 7. We will write Java applications that connect to all of these ports.

In the interest of brevity, I am not going to provide a complete list of ports and their services. However, you should be able to find all the information you might need about port numbers and the services they support by

starting your favorite search engine and searching for " well known ports"

vy

Firewalls

You may have heard about firewalls . A firewall is the common name given to the equipment and associated software that is used to insulate the network inside of a company from the Internet at large outside the company. Typically, the firewall will restrict the degree to which computers inside the company can communicate with the Internet for security and other reasons.

Proxy Servers

You may also have heard about proxy servers . A proxy server acts as an interface between computers inside the company and the Internet at large.

Oftentimes the proxy server will have the ability to cache web pages for limited periods of time. For example, if ten people inside the company attempt to connect to the same Internet server and download the same web page within a (hopefully) short period of time, that page may be saved on the proxy server on the first attempt and then delivered to the next nine people without re-acquiring it from the outside web server. This can significantly improve delivery time and reduce network traffic into and out of the company. It can also result in the delivery of stale pages in some cases.

Standards and Protocols

At some point, you may be interested in obtaining technical information about Internet standards and protocol specifications. A good place to start

looking for such information is http://www.w3.org/pub/WWW/Protocols/ .

URL

URL is an acronym for Uniform Resource Locator . (It is also the name of a class in Java.) A URL is a pointer to a particular resource at a particular location on the Internet. A URL specifies the following:

e the protocol used to access the server (such as http)

e the name of the server

e the port on the server (optional)

e the path and name of a specific file on the server (sometimes optional) e the anchor or reference point within the file (optional)

Sometimes the name of the file can be omitted, in which case an HTTP browser will usually append the file name index.html to the specified path and try to load that file. For example, as of this writing, you can connect to my home page on the HTTP server at Austin Community College using either of the following URLs:

e http://www.austincc.edu/baldwin/ e http://www.austincc.edu/baldwin/index.html

In addition to specifying the name of the file of interest, it is also sometimes possible to specify an anchor or reference that has been established inside the file. The anchor is identified by the text following the # character in the URL.

For example, as of this writing, the following URL will take you to a specific location inside one of my modules on Java servlets.

http://cnx.org/content/m48518/latest/#Images

(Note the #Images at the end of the URL. That is commonly known as the anchor .)

The general syntax of a URL is as follows:

protocol://hostname[:port]/path/filename#ref

The port is optional, and is not normally required if you are accessing a

server that provides the required service on a standard port. The browser (or

other software being used to connect) should know which port supports the specified protocol and should connect to that port by default.

You could fill in the optional port number and use the following URL to access the same location in my servlets module, but that would simply require you to do some extra typing.

http://cnx.org:80/content/m48518/latest/#Images

However, if you were to change the 80 to a 25, you would not be able to connect and successfully communicate with the server because the server does not support the HTTP protocol on port 25. In fact, here is the text of the Firefox error message that resulted from me doing that:

"This address is restricted This address uses a network port which is normally used for purposes other than Web browsing. Firefox has canceled the request for your protection."

The Google Chrome browser simply provided the following error message when I attempted to do that.

"This webpage is not available."

When I clicked a "More" button on the Chrome error message, this is what I

got:

"The webpage at http://cnx.org:25/content/m48518/latest/#Images might be

temporarily down or it may have moved permanently to a new web address. Error code: ERR_UNSAFE_PORT"

Note, however, that we will be properly addressing port 8080 on a particular server in some future modules. Since 8080 is not a standard port, it will be necessary for us to enter the port number following a colon in order to access the material on the server.

Socket Classes and the URL Class

Java provides at least two different approaches for doing network programming (and possibly more) , insofar as the web is concerned. The two approaches are associated with

e The Socket , DatagramSocket , and ServerSocket classes e The URL, URLEncoder, and URLConnection classes.

Socket Programming

Socket programming primarily makes use of two socket classes named Socket and DatagramSocket along with the ServerSocket class. The first two socket classes represent TCP and UDP communications respectively.

Generally, the two socket classes are used to implement both clients and servers , while the ServerSocket class is only used to implement servers . We will see several examples of socket programming in this series of modules.

Socket programming provides a low-level approach by which you can connect two computers for the exchange of data. One of those is generally considered to be the client while the other is considered to be the server .

Although the distinction between client and server is becoming less clear each day, there is one fundamental distinction that is inherent in the Java

programming language.

The client initiates conversations with servers, while servers block and wait for a client to initiate a conversation.

The governing application-level protocol will determine what happens after the connection is made and the conversation has begun. The fact that the two computers can connect doesn't necessarily mean that they can communicate. In order to communicate, they must implement some mutually acceptable application protocol

For example, the fact that I can dial a telephone number for a telephone located in France doesn't mean that I can communicate with the person who answers the phone. I don't know how to speak the French language. Unless the person who answers the phone speaks English, very little communication is likely to take place.

Socket programming has been around for quite a while in the Unix world. Java simply makes it easier by encapsulating much of the complexity of socket programming into classes, and allowing you to approach the task on an object-oriented basis.

On the other hand, according to some authors, some of the generality and capability that Unix socket programmers have enjoyed has been lost in the encapsulation process.

Basically, socket programming makes it possible for you to cause data to flow in a full-duplex mode between a client and a server. This data flow can be viewed in almost exactly the same way that we view data flow to and from a disk: as a stream of bytes.

As with most stream data processing, the system is responsible for moving the bytes from the source to the destination. It is the responsibility of the programmer to assign meaning to those bytes.

Assigning meaning takes on a special significance for socket programming. In particular, as mentioned above, it is the responsibility of the programmer to implement a mutually acceptable communication protocol at the application level to cause the data to flow in an orderly manner.

An application protocol is a set of rules by which the programs in the two computers can carry on a conversation and transfer data in the process. For example, we will also write a program that implements a very abbreviated form of the HTTP protocol to download web pages from a server and display them.

We will also write a program that functions as an (abbreviated) HTTP server to deliver web pages to a client and also supports the echo protocol for both TCP and UDP programming.

Each of these programs will involve adherence to a fairly simple protocol. (At least the part that we implement will be fairly simple) .

In addition, we will also write a program that obtains the date and time from another computer. In this case, the protocol will be about as simple as it can possibly be. The client will simply make the connection and listen for a string containing the date and time. This will be sort of like dialing the local time service, except that we won't have to listen to an advertisement before getting the time.

The bottom line is that with socket programming, it is easy to write code that will cause a stream of bytes to flow in both directions between a client and a server. This is no more difficult than causing a stream of bytes to flow in both directions between memory and a file on a disk.

However, getting the bytes to flow is the easy part. Beyond that, you must

do all of the programming to implement an application protocol that is understood by both the client and the server.

URL Programming

URL programming occurs at a higher level than socket programming, and in theory represents a very powerful idea.

In theory, by using the URL class, you can open a connection to a resource on the web, specified by a URL object, and simply call the getContent method on that URL object. The content of the resource will then be magically downloaded and will appear as an object on the client machine, even if it requires an application protocol that didn't exist when you wrote the program, and contains content that you didn't understand when you wrote the program.

This description may be a bit of an overstatement, but it is pretty close to the claims being made. This is a powerful idea, which may or may not bear fruit in the future.

If fully implemented by browsers, the idea means that you can place new and unusual material on a web site along with special content handlers and protocol handlers. Then a cooperating browser will use those special handlers to move that material from the web site to the client and interpret its content once it gets there without a requirement to install software (such as plug-ins) on the client computer on a permanent basis.

Here is what Peter van der Linden has to say about this topic in his excellent book titled Just Java 1.1 and Beyond:

"If a browser doesn't recognize a media type, it should be able to download the code to process it from the same place it got the file. If they ever get this working, it will be ... a good thing."

Is it working, or will they ever get it working? I don't know. If it depends on cooperation among all the major players, including the major browser vendors - probably not. Therefore, I don't plan to spend much time on the topic of protocol and content handlers until I see some evidence that it is working to such an extent that it is practically useful.

That is not to say that you couldn't use the capability right now if you were developing an intranet and wanted the clients to have access to new and unusual content. It would be necessary for you to provide the appropriate protocol and content handlers, and it would probably be necessary for the clients to run Java applications written by you instead of standard browsers to access the data.

Also, the URL class provides an alternative way to connect one computer to another and transfer data on a stream basis, so we will see some examples of retrieving data from a server by obtaining a URL connection, and then opening and servicing I/O streams between the client and the server. We will see some sample programs that make use of this technique, but we will also see that it is somewhat redundant with the socket programming approach.

A local area network

This is part of a sub-collection of modules designed for teaching network programming. Therefore, you may find some of the modules more meaningful if you are able to connect two or more computers in a local area network and run the sample programs across the network.

However, it is possible to simulate a network inside a single computer. If you are unable to create an actual network, you should be able to run all of the sample programs by simulating a network in your single computer.

The operating system

While the capabilities of Java are generally independent of the operating system in use, the manner in which an individual computer must be configured for network operation is generally not independent of the operating system.

In those cases where these modules provide instructions for configuring the computer, those instructions will assume a Windows operating system. If you are using a different operating system, you will need to translate those instructions into your operating system.

What's Next?

We will learn how to use the Java InetAddress class to find the domain name corresponding to an IP address, and to find the IP address corresponding to a domain name in our sample program in the next module.

Miscellaneous

This section contains a variety of miscellaneous information.

Note: Housekeeping material

e Module name: Java4620: General Information e File: Java4620.htm

e Published: 03/02/14

e Revised 12/26/14

Note: Disclaimers:

Financial : Although the Connexions site makes it possible for you to download a PDF file for this module at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should be aware that some of the HTML elements in this module may not translate well into PDF.

I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module. In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. I neither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please be aware that it is a copy of a module that is freely available on cnx.org and that it was made and published without my prior knowledge.

Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.

-end-

Java4620r-Review

This module is one in a collection of modules designed for teaching INEW 2338 Advanced Java (Web) at Austin Community College in Austin, TX. This module contains review questions and answers keyed to the module titled Java4620: General Information in the Network Programming sub- collection.

Table of Contents

e Preface e Questions

Odes dy Oey Oy Oe 2 ey Oy A, 1 1 I A ee i I

e Answers e Miscellaneous

Preface

This module is one in a collection of modules designed for teaching INEW 2338 Advanced Java (Web) at Austin Community College in Austin, TX.

This module contains review questions and answers keyed to the module titled Java4620: General Information in the Network Programming sub- collection.

Once you study that module, you should be able to answer the review questions in this module.

The questions and the answers in this module are connected by hyperlinks to make it easy for you to navigate from the question to the answer and back again.

Questions

Question 1 True or False?

A network is a group of computers and other devices that are connected in some fashion for the purpose of exchanging data.

Go to answer 1

Question 2 True or False?

Each of the devices on the network can be thought of as a node , and each node has the same address.

Go to answer 2

Question 3 True or False? Modern networks transfer data using a concept known as packet switching .

Go to answer 3

Question 4 True or False?

In order for two or more computers connected to a network to be able to exchange data in an orderly manner, each computer must use a different protocol. The protocol defines the rules by which they communicate.

Go to answer 4

Question 5 True or False?

The HTTP protocol defines how web browsers and servers communicate and the SMTP protocol defines how some email is transferred

Go to answer 5

Question 6 True or False? IP is an acronym that stands for Interconnection Protocol.

Go to answer 6

Question 7 True or False?

IP is a network protocol that moves packets of data from a source to a destination. As the name implies, this is the protocol normally used on the Internet.

Go to answer 7

Question 8

True or False?

The Transmission Control Protocol (‘TCP ) was added to IP to give each end of a connection the ability to acknowledge receipt of IP packets and to request retransmission of corrupted or lost packets. Also TCP makes it possible to put the packets back together at the destination in the same order that they were sent.

Go to answer 8

Question 9 True or False?

TCP and IP work together to provide a reliable method of encapsulating a message into data packets, sending the packets to a destination, and reconstructing the message from the packets at the destination.

Go to answer 9

Question 10 True or False?

The User Datagram Protocol ( UDP) is even more reliable than TCP/IP in guaranteeing that a series of packets will arrive in the right order. However, UDP involves a high level of overhead and the data transfer rate may be slow.

Go to answer 10

Question 11

True or False?

Every computer attached to an IP network has a unique address, typically consisting of four bytes or 32 bits. Efforts are underway to expand the number of possible unique addresses to a much larger number. The planned number is the number of unique addresses that can be represented with a 128-bit address.

Go to answer 11

Question 12

True or False?

For human consumption, we usually convert the value of each of the IP address bytes to an unsigned decimal value and display them connected by periods to make them easier to remember. For example, a typical IP address

might be 206.77.150.222 .

Go to answer 12

Question 13 True or False? Most IP addresses have a corresponding name known as a domain name .

Go to answer 13

Question 14 True or False?

The Domain Name of a destination server is encapsulated into data packets and used by the internet protocol to route those packets from the source to

the destination.

Go to answer 14

Question 15 True or False?

The Java InetAddress class can often be used to find the domain name corresponding to an IP address, and to find the IP address corresponding to a domain name.

Go to answer 15

Question 16 True or False?

Each server computer that you may connect to will be logically organized into ports . Theoretically, there are a large number of available ports. A subset of those port numbers are predefined to be used for certain standard services. For example, if you want to connect with a public server that communicates using the HTTP protocol, you would normally connect to port 80 on the server of interest.

Go to answer 16

Question 17 True or False?

A firewall is the common name given to the equipment and associated software that is used to improve the communication speed of computers

inside of a company with the Internet at large outside the company.

Go to answer 17

Question 18 True or False?

A proxy server is the common name given to the equipment and associated software that is used to insulate the network inside of a company from the Internet at large outside the company. Typically, the firewall will restrict the degree to which computers inside the company can communicate with the Internet for security and other reasons.

Go to answer 18

Question 19 True or False?

URL is an acronym for Uniform Resource Locator . (It is also the name of a class in Java.) A URL is a pointer to a particular resource at a particular location on the Internet.

Go to answer 19

Question 20 True or False? A URL specifies the following:

e the protocol used to access the server (such as http) e the name of the server

e the port on the server (optional) e the path and name of a specific file on the server (sometimes optional) e the anchor or reference point within the file (optional)

Go to answer 20