Internet & Java Programming Lecture Notes, Lecture notes of Java Programming

Internet & Java Programming Lecture Notes

Typology: Lecture notes

2014/2015

Uploaded on 12/06/2015

veer.Nath
veer.Nath 🇮🇳

5

(1)

1 document

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Format of an HTTP Request
It has three main components, which are:-
HTTP Request Method, URI, and Protocol Version - this should always be the first line of an
HTTP Request. As it's quite evident from the name itself, it contains the HTTP Request method
being used for that particular request, the URI, and the HTTP protocol name with the version
being used. It may look like 'GET /servlet/jspName.jsp HTTP/1.1' where the request
method being used is 'GET', the URI is '/servlet/jspName.jsp', and the protocol (with
version) is 'HTTP/1.1'.
HTTP Request Headers - this section of an HTTP Request contains the request headers, which
are used to communicate information about the client environment. Few of these headers
are: Content-Type, User-Agent,Accept-Encoding, Content-Length, Accept-
Language, Host, etc. Very obvious to understand what info do these headers carry, isn't it? The
names are quite self-explanatory.
HTTP Request Body - this part contains the actual request being sent to the HTTP Server. The
HTTP Request Header and Body are separated by a blank line (CRLF sequence, where CR
means Carriage Return and LF means Line Feed). This blank line is a mandatory part of a valid
HTTP Request.
Format of an HTTP Response
Similar to an HTTP Request, an HTTP Response also has three main components, which are:-
Protocol/Version, Status Code, and its Description - the very first line of a valid HTTP
Response is consists of the protocol name, it's version, status code of the request, and a short
description of the status code. A status code of 200means the processing of request was
successful and the description in this case will be 'OK'. Similarly, a status code of '404' means the
file requested was not found at the HTTP Server at the expected location and the description in
this case is 'File Not Found'.
HTTP Response Headers - similar to HTTP Request Headers, HTTP Response Headers also
contain useful information. The only difference is that HTTP Request Headers contain information
about the environment of the client machine whereas HTTP Response Headers contain
information about the environment of the server machine. This is easy to understand as HTTP
Requests are formed at the client machine whereas HTTP Responses are formed at the server
machine. Few of these HTTP Response headers are: Server, Content-Type, Last-
Modified, Content-Length, etc.
HTTP Response Body - this the actual response which is rendered in the client window (the
browser window). The content of the body will be HTML code. Similar to HTTP Request, in this
case also the Body and the Headers components are separated by a mandatory blank line (CRLF
sequence).
HTTP Request Types:
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Internet & Java Programming Lecture Notes and more Lecture notes Java Programming in PDF only on Docsity!

Format of an HTTP Request

It has three main components, which are:-

  • HTTP Request Method, URI, and Protocol Version - this should always be the first line of an HTTP Request. As it's quite evident from the name itself, it contains the HTTP Request method being used for that particular request, the URI, and the HTTP protocol name with the version being used. It may look like 'GET /servlet/jspName.jsp HTTP/1.1' where the request method being used is 'GET', the URI is '/servlet/jspName.jsp', and the protocol (with version) is 'HTTP/1.1'.
  • HTTP Request Headers - this section of an HTTP Request contains the request headers, which are used to communicate information about the client environment. Few of these headers are: Content-Type, User-Agent,Accept-Encoding, Content-Length, Accept- Language, Host, etc. Very obvious to understand what info do these headers carry, isn't it? The names are quite self-explanatory.
  • HTTP Request Body - this part contains the actual request being sent to the HTTP Server. The HTTP Request Header and Body are separated by a blank line (CRLF sequence, where CR means Carriage Return and LF means Line Feed). This blank line is a mandatory part of a valid HTTP Request.

Format of an HTTP Response

Similar to an HTTP Request, an HTTP Response also has three main components, which are:-

  • Protocol/Version, Status Code, and its Description - the very first line of a valid HTTP Response is consists of the protocol name, it's version, status code of the request, and a short description of the status code. A status code of 200 means the processing of request was successful and the description in this case will be 'OK'. Similarly, a status code of ' 404 ' means the file requested was not found at the HTTP Server at the expected location and the description in this case is 'File Not Found'.
  • HTTP Response Headers - similar to HTTP Request Headers, HTTP Response Headers also contain useful information. The only difference is that HTTP Request Headers contain information about the environment of the client machine whereas HTTP Response Headers contain information about the environment of the server machine. This is easy to understand as HTTP Requests are formed at the client machine whereas HTTP Responses are formed at the server machine. Few of these HTTP Response headers are: Server, Content-Type, Last- Modified, Content-Length, etc.
  • HTTP Response Body - this the actual response which is rendered in the client window (the browser window). The content of the body will be HTML code. Similar to HTTP Request, in this case also the Body and the Headers components are separated by a mandatory blank line (CRLF sequence).

• HTTP Request Types:

  • We have already seen the GET request type in the above example, let's see some more

types of HTTP request types.

  • HTTP Head Request
  • HTTP head request is very much similar to the GET request. Its the easiest method to

know the complete details of the resource available on a particular URL, without downloading the entire data.

  • For example, if we use HEAD request in our above example, we will get all the header's

in the response except our page containing the "Hello" message.

  • This kind of a request is used only to retrieve attributes of the data without the data. This

can give you information about the resource by saving your bandwidth.

  • (^) HTTP Post Request
  • POST request is mostly used to send data from the client to the server. Let's see an

example of HTTP post request from the client to the server.

  • HTTP Put request:
  • HTTP put request is very much similar to the post request. PUT request sends or creates

a resource in the specified URI.

  • IF the resource is already present in that specified URI, it will update that URI, otherwise

it will create the resource.

  • HTTP Delete Request:
  • HTTP delete request deletes a specified resource on a specified URI.
  • It's not at all advisable to configure a webserver for HTTP delete operation. However if

you want to enable such functionalities, its better to that with a http POST operation using a web form, which intern will delete a resource.

  • HTTP Trace Request
  • HTTP trace request is used to trouble shoot http web pages.
  • For example, if suppose a web page is not getting loaded the way you want in your

browser. Then in such cases http trace request can be used to retrieve the complete request that the server got from the client back to the client itself.

  • This kind of request kind is mostly disabled in most of the web server's. The main reason

is that its very much similar to viewing the web server log of the request you send.

First, you as client make a TCP control connection to the FTP server's port 21 which will remain

open during the transfer process. In response, the FTP server opens a second connection that is the

data connection from the server's port 20 to your computer.

Using the standard active mode of FTP, your computer communicates the port number where it will

stand by to receive information from the controller and the IP address--internet location--from which

or to which you want files to be transferred.

If you are using a public--or anonymous--FTP server, you will not need proprietary sign-in

information to make a file transfer, but you may be asked to enter your email address. If you are

using a private FTP server, however, you must sign in with a user name and password to initiate the

exchange of data.

Modes of File Transfer

Three modes of transferring data are available via FTP. The system can use a stream mode, in

which it transfers files as a continuous stream from port to port with no intervention or processing of

information into different formats. For example, in a transfer of data between two computers with

identical operating systems, FTP does not need to modify the files.

In block mode, FTP divides the data to be transferred into blocks of information, each with a header,

byte count, and data field. In the third mode of transfer, the compressed mode, FTP compresses the

files by encoding them. Often these modifications of data are necessary for successful transfer

because the file sender and file receiver do not have compatible data storage systems.

Passive FTP

Should your computer have firewall protection, you may have difficulties using FTP. A firewall

protects your PC by preventing internet sites from initiating file transfers. You can circumvent your

firewall's function by using the PASV command that reverses the FTP process, allowing your

computer to initiate the transfer request.

Many corporate networks use PASV FTP as a security measure to protect their internal network from

assaults of unwanted external files. Also called passive FTP, the process requires that any transfer of

information from the internet or other external source must be initiated by the client or private

network rather than the external source.

Further FTP Security

In response to the need for a more secure transfer process for sensitive information such as

financial data, Netscape developed a Secure Sockets Layer (SSL) protocol in 1994 that it used

primarily to secure HTTP--HyperText Transfer Protocol--transmissions from tampering and

eavesdropping. The industry subsequently applied this security protocol to FTP transfers,

developing SFTP, a file transfer protocol armored with SSL for protection from hackers.

Objectives of FTP were:

1. to promote sharing of files (computer programs and/or data),

2. to encourage indirect or implicit (via programs) use of remote computers,

3. to shield a user from variations in file storage systems among hosts, and

4. to transfer data reliably and efficiently.

What Is Email Protocol?

Email protocol is a method by which a communication channel is established between two computers and email is transferred between them. When an email is transferred, a mail server and two computers are involved. One computer sends the mail and the other one receives it. The mail server stores the mail and lets the receiving device access it and download it if needed. There are four different mail protocols. These protocols differ in the way by which they establish connections and allow user access to emails.

Read more: http://www.ehow.com/about_6168931_email-protocol_.html#ixzz2ktWLtS2E

Usage in Various Email Applications

  • Various email applications exist. Microsoft Outlook is one of the most popular commercial applications. Lotus Notes is another particularly common one. These applications can support various email protocols. Different ports are used for different mail protocols. Microsoft Outlook can support mail servers compatible with IMAP and POP3 protocols. UNIX machines and simple mail applications support SMTP protocol. Following are the different email protocols.

POP3 (Post Office Protocol 3)

  • This is a simple, standardized protocol that allows users to access their mailboxes on the Internet and download messages to their computers. The simple design of POP3 allows casual email users who have a temporary Internet connection (dial-up access) to access emails. They can read their emails, draft new emails or reply to emails while they are offline, and can send these emails when they are back online. Yahoo! Mail (mail.yahoo.com) is an example of a mail server that uses POP3 protocol.

Hotmail and Yahoo! use HTTP protocol for accessing emails through the Internet.

MAPI

As noted, MAPI is Microsoft's proprietary email protocol. It provides greater functionality than IMAP for Outlook email clients interacting with an Exchange email server. It doesn't work for anything else. (In Outlook you may simply see the connection option "Microsoft Exchange Server" rather than MAPI. It's offering the same thing.)

Remote access using MAPI may require use of a VPN connection, because the ports (communications channels) that MAPI uses are otherwise blocked for security reasons. (That's the case when accessing the medical campus Exchange system remotely.)

Dial-up Internet Connectivity

Today, dial-up Internet connectivity is the most common type of access promoted by ISPs or Internet Service Providers. The connection is cheap and slow, but enables users to connect via a local server, that exhibits strength of a standard 56 Kilobits per second modem. Dial-up Internet access is basically, access to the Internet via integrated telephone lines. The user's router or computer enables access via the attached modem, which in turn connects to the preferred Internet service provider's node. The resultant modem-to-modem link empowers the routing of dedicated Internet Protocol Packets on the Internet. The technology has come a long way, to establish computer-based telecommunication between terminal emulator software, to integrated mainframes, online services, minicomputers and dedicated bulletin board systems. The technology does not require any infrastructure, other than a telephone connection. The dial-up Internet connection is very useful to travelers and for access in rural or remote areas. It appeals to users on limited budgets.

Broadband Internet Connection

The term 'Broadband Internet Connection' has different meanings in different contexts. In the world of data communication, it refers to data transmission over a fiber optic cable. In the case of a DSL or Digital Subscriber Line, this service relates to the transfer of digital information over a high-bandwidth channel; while on the Ethernet, the technology implies a baseband transmission using the complete bandwidth of the preferred medium (as in the case of 100BASE-T Ethernet). In power-line communication, it refers to high-speed signaling to achieve high data rates (as in the case of ITU-T G.hn standard); while in video distribution the term refers to the modulation of individual channels, at fixed frequencies. Broadband Internet connectivity in telecommunication refers to a specially developed signaling system that integrates a wide frequency range (or band). Basically, the technology enables greater information-carrying capacity and quicker Internet access.

What is the difference between dial up and broadband Internet connections?

The fundamental difference between dialup and broadband connections is the manner in which the connection is made from PC to the Internet.

A dialup service connects to the Internet through a phone line with a maximum speed of 56kbps.

Broadband refers to a connection that has capacity to transmit large amount of data at high speed. Presently a connection having download speeds of 256kbps or more is classified as broadband.

Broadband comes in a number of forms - depending how the data is delivered - for example via cable, satellite and most commonly using a telephone line where as a dialup service always connects to the Internet through a phone line.

While using a dialup connection, we need to pay for a local call every time we dial the Internet. In addition phone line is engaged while we are on the Internet. With a broadband connection, phone line (if existing phone line is used) can still be used while using the Internet and both the phone and the Internet work simultaneously and no dialup costs are incurred. Telecommunication systems were originally built to carry analogue signals. In a dial up connection, modems are used to translate digital into analogue signals and communicating with Internet.

However, analogue transmission between the subcriber and the telephone company is a bandwidth bottleneck. Dialup connection speeds make it more difficult to view certain types of media, such as video, and it can take much longer to download and open emial attachments, play online games and so on.

In an broadband system, digital data does not have to be converted into analogue. it uses a different part of the line's frequency spectrum, offers much wider bandwidth 9more lanes) and does not interfere with the use of the line for voice transmission. When connected to the Internet, such a connection allows surfing or downloading much faster than a dial-up connection. Dialup connection users a built-in modem to connect and does not require a special router, whereas broadband requires a special router or modem.

In terms of security for attack, dialup is more secured then broadband, Broadband users need to use a firewall to keep the computer "invisible" to the outside.

How to Create a Dial-Up Connection in Windows XP

  1. From the Start menu, choose Control Panel.
  2. Click the Network and Internet Connections icon.
  3. Click the Set up or change your Internet connection icon.
  4. Click the Setup button.
  5. Click the Next button.
  6. (^) Select Connect to the Internet.
  7. Click the Next button.
  8. Select Set up my connection manually.
  9. Click the Next button.
  1. (^) Click the Finish button.

You have successfully created a Dial-up Connection in Windows XP.

E-commerce (electronic commerce or EC) is the buying and selling of goods

and services on the Internet, especially the World Wide Web. In practice, this

term and a newer term, e-business, are often used interchangably. For online

retail selling, the term e-tailing is sometimes used.

E-commerce can be divided into:

  • E-tailing or "virtual storefronts" on Web sites with online catalogs, sometimes gathered into a "virtual mall"
  • The gathering and use of demographic data through Web contacts
  • Electronic Data Interchange (EDI), the business-to-business exchange of data
  • E-mail and fax and their use as media for reaching prospects and established customers (for example, with newsletters)
  • Business-to-business buying and selling
  • The security of business transactions

Often referred to as simply ecommerce (or e-commerce) the phrase is used to describe

business that is conducted over the Internet using any of the applications that rely on the

Internet, such as e-mail, instant messaging, shopping carts, Web services, UDDI, FTP, and EDI,

among others. Electronic commerce can be between two businesses transmitting funds, goods,

services and/or data or between a business and a customer.

E-commerce refers to the purchase and sale of goods and/or services via electronic channels, such as the Internet. Online retail is convenient due to its 24-hour availability, global reach and ease of customer service.

Though purchasing items online is a major facet, e-commerce is more than that. This type of commerce can be useful at the enterprise level as well. E-commerce is not just on the Web — it was first introduced in the 1960s via electronic data interchange (EDI) through value-added networks (VANs). In the mid-1990s, e-commerce was transformed with the introduction of Amazon and eBay. Amazon started as a book shipping business, out of Jeff Bezos' garage, in 1995. EBay, which enabled consumers to sell things online, introduced online auctions in 1995 and exploded with the 1997 Beanie Babies frenzy.

There are four main categories: B2B, B2C, C2B, and C2C.

  • B2B (Business to Business) — this kind of e-commerce involves companies doing business with each other. One example is manufacturers selling to distributors and wholesalers selling to retailers.
  • B2C (Business to Consumer) — This is what most people think of when they hear "e- commerce." B2C consists of businesses selling to the general public through shopping cart software, without needing any human interaction. An example of this would be Amazon.
  • C2B (Consumer to Business) — In this scenario, a consumer would post a project with a set budget online, and companies bid on the project. The consumer reviews the bids and selects the company — Elance is an example of this.
  • C2C (Consumer to Consumer) — this type of e-commerce is made up of online classifieds or forums where individuals can buy and sell their goods, thanks to systems like PayPal. An example of this would be eBay or etsy.
  • E-commerce strategy

Just like any type of business, e-commerce businesses need to have a fully fleshed strategy. The first step is to set goals. Do you plan to increase revenue from existing customers? Gain new customers? Increase the average order value? Sell through new channels? Lower prices? Once you have figured out your goals, the next step is to set a plan.

Your first step is to conduct a SWOT analysis and assess the strengths, weaknesses, opportunities and threats of where your business is. What does the market look like? Where does your business excel, and where does it falter? Review your entire business, not just segments of it. Evaluate external opportunities, because this is the often the primary place to invest time and money. Be honest with yourself when analyzing weaknesses and threats, or else the analysis will not be helpful.

After the SWOT analysis is done, see how it fits into your overall vision. Where do you see your business in five years? In 10 years? This will help you set business objectives for the current year, where you set objectives for sales, profits, customers, traffic, new systems, and new staff. After the objectives are set, a strategy can be put in place, either by you or by a hiring an e-commerce consultant.

In addition to having a strong business strategy, it's important to have a basic understanding of e-commerce law. There are different legal and financial considerations, especially with privacy, security, copyright, and taxation. The Federal Trade Commission (FTC) regulates most e-commerce activities, including the use of commercial emails, online advertising, and consumer privacy. Through any average day, businesses collect and retain personal information from their customers — information that is often sensitive. You are subject to federal and state privacy laws, depending on the type of data that you collect.

There are also online advertising laws that protect consumer privacy and ensure truthful marketing practices online. As an e-commerce business, online advertising is a major part

  • The current version is CGI/1.1 and CGI/1.2 is under progress.

Web Browsing

To understand the concept of CGI, lets see what happens when we click a hyper link to browse a particular web page or URL.

  • Your browser contacts the HTTP web server and demands for the URL i.e., filename.
  • Web Server will parse the URL and will look for the filename in if it finds that file then sends it back to the browser, otherwise sends an error message indicating that you have requested a wrong file.
  • Web browser takes response from web server and displays either the received file or error message.

However, it is possible to set up the HTTP server so that whenever a file in a certain directory is requested that file is not sent back; instead it is executed as a program, and whatever that program outputs is sent back for your browser to display. This function is called the Common Gateway Interface or CGI and the programs are called CGI scripts. These CGI programs can be a Python Script, PERL Script, Shell Script, C or C++ program, etc.

CGI Architecture Diagram

CGI Environment Variables

All the CGI program will have access to the following environment variables. These variables play an important role while writing any CGI program.

Variable Name Description CONTENT_TYPE The data type of the content. Used when the client is sending attached content to the server. For example, file upload, etc.