http, server & client communication

31
Http, server & client communication Next Last

Upload: lorna

Post on 10-Feb-2016

60 views

Category:

Documents


0 download

DESCRIPTION

Http, server & client communication. Last. Next. Web server and web browser. It’s a take and give policy in between client and server through HTTP(Hyper Text Transport Protocol) Server takes a request from client and return something back to client. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Http, server & client communication

Http, server & client

communication

NextLast

Page 2: Http, server & client communication

Web server and web browser

It’s a take and give policy in between client and server through HTTP(Hyper Text Transport Protocol)

Server takes a request from client and return something back to client.

Take and give routine is done through browser.Web browser provides the platform to access

server content on client machine.

NextLast

Page 3: Http, server & client communication

Cont’d …..

NextLast

Page 4: Http, server & client communication

The client’s request contains the name and address (the URL), of the thing the client is looking for.

Usually the server has a lot of “contents” that has to be sent to client. That contents WebPages, images and other resource.

The server’s response contains the actual document that the client requested (or an error code if the request could not be processed).

NextLast

Page 5: Http, server & client communication

What does a web client does?A web client lets the user request something on

the server, and shows the user the result of the request.

The browser is the piece of software that knows how to communicate with the server. So from now on, when we use the term client, we usually won’t care whether we’re talking about the human user or the browser app. In other words, the client is the browser app doing what the user asked it to do.

NextLast

Page 6: Http, server & client communication

Communication between Server and browser

NextLast

Page 7: Http, server & client communication

Clients and servers know HTML and HTTP

When a server answers a request, the server usually sends some type of content to the browser so that the browser can display it.

Server sends instruction/data to browser in html(hyper text mark up language)

Most of the conversations held on the web between clients and servers are held using the HTTP protocol, which allows for simple request and response conversations.

NextLast

Page 8: Http, server & client communication

What the hell browser creates ?

The browser is a application software reads through the HTML code which information sent by the server to the client according to the client request, creates the web page, and renders it to the user’s display.

NextLast

Page 9: Http, server & client communication

What exactly is the HTTP Protocol ?HTTP - It means Hyper Text Transport Protocol.HTTP runs on top of TCP/IP. Then ,what is TCT/IP.TCP is responsible for making sure that a file

sent from one network node to another ends up as a complete file at the destination, even though the file is split into chunks when it’s sent.

IP is the underlying protocol that moves/routes the chunks (packets) from one host to another on their way to the destination.

NextLast

Page 10: Http, server & client communication

Continued……HTTP, then, is another network protocol that has

Web-specific features, but it depends on TCP/IP to get the complete request and response from one place to another. The structure of an HTTP conversation is a simple Request/ Response sequence; a browser requests, and a server responds.

Key elements of Request Responds

NextLast

Page 11: Http, server & client communication

Continued……

Key elements of Request HTTP method (The action to be performed) The page to access (A URL) Form parameters (Like arguments to methods)

Key elements of Respond A status code(To check whether the request was

successful or not ) The content -type(Text, pictures, movies, HTML and etc) The content(The actual HTML, images and etc)

NextLast

Page 12: Http, server & client communication

Continued……

NextLast

Page 13: Http, server & client communication

HTML is part of the HTTP response An HTTP response can

contain HTML. HTTP adds header information to the top of whatever content is in the response (in other words, the thing coming back from the server). An HTML browser uses that header info to help process the HTML page.

HTTP Body

HTTP Header

NextLast

Page 14: Http, server & client communication

If that’s the response, what’s in the request? The first ?

One of the important features is an HTTP method name. These aren’t Java methods, but the idea is similar.

The method name speaks the server the kind of request that’s being made, and how the rest of the message will be formatted. The HTTP protocol has several methods.

GETPOST

NextLast

Page 15: Http, server & client communication

Continued……

GET METHOD

NextLast

Page 16: Http, server & client communication

POST METHOD

NextLast

Page 17: Http, server & client communication

Magic Get & PostGET is the simplest HTTP method, and its main job in

life is to ask the server to get a resource and send it back.

The point of GET is to get something back from the server.

POST is a more powerful request. It’s like a GET plus plus. With POST, you can request something and at the same time send form data to the server (later in this chapter we’ll see what the server might do with that data).

NextLast

Page 18: Http, server & client communication

Some other Http methods besides get & post

Those are the two big ones that everybody uses. But there are a few rarely used methods (and Servlets can handle them) including HEAD, TRACE, PUT, DELETE, OPTIONS, and CONNECT.

NextLast

Page 19: Http, server & client communication

Get or Post which one is better

The total amount of characters in a GET is really limited , hence it is not useful for bigger data.

The data you send with the GET is appended to the URL up in the browser bar. So, whatever you send is exposed. So there is less security in Get method.

The user can’t bookmark a form submission if you use POST instead of GET.

NextLast

Page 20: Http, server & client communication

URL explanations

URL - Uniform Resource Locators

http:// www.wickedlysmart.com:80 / select / beer1.html

Protocol Server Port Path Resource

NextLast

Page 21: Http, server & client communication

Protocol , Server & Url Protocol set of rules which tells the server how

communications will be held. Server is the unique name of the physical server you’re

looking for. This name maps to a unique IP address. IP addresses are numeric and take the form “xxx.yyy.zzz.aaa”. You can specify an IP address here instead of a server name, but a server name is a lot easier to remember.

URL is optional. A single server supports many ports. A server application is identified by a port. If you don’t specify a port in your URL, then port 80 is the default, and as luck would have it, that’s the default port for web servers.

NextLast

Page 22: Http, server & client communication

Path & ResourcesPath: The path to the location, on the server, of the

resource being requested. Because most of the early servers on the web ran Unix, Unix syntax is still used to describe the directory hierarchies on the web server.

Resource: The name of the content being requested. This could be an HTML page, a servlet, an image, PDF, music, video, or anything else the server feels like serving. If this optional part of the URL is left out, most web servers will look for index.html by default.

NextLast

Page 23: Http, server & client communication

Reserved Ports

Be care full , never fix your port to these reserved ports. Nex

tLast

Page 24: Http, server & client communication

As web Server Loves to love to serve Static web pages

As a static page sits there in a directory. The server finds and hands it back to client as it is . Each and every client sees same thing .

The page goes client exactly same as it was placed in the server .

NextLast

Page 25: Http, server & client communication

Servlet There are many advantages to using Java over

Perl for the things you want to do with CGI. Performance, for one thing.

With Perl, the server has to launch a heavy-weight process for each and every request for that resource!

Servlets stay loaded and client requests for a Servlet resource are handled as separate threads of a single running Servlet.

NextLast

Page 26: Http, server & client communication

Tier ArchitectureTier architecture is three

types - Single tier architecture Two tier architecture Three tier architecture

Single tier architecture combines all Presentation ,logic and data and keep at one place. There is no separation of data, logic and presentation.

Display

Logic

Data

Single tier Architecture

Page 27: Http, server & client communication

Servlet Demystified (write, deploy, run) in Tomcat apache server

However we are here working on Tomcat apache server.

So to work on tomcat we have to create a directory tree as like below under the webapps.

NextLast

Page 28: Http, server & client communication

Continued….Well to deploy your Servlet program you have to create a

folder according your choice inside of the webapps folder.example - holiday

Then create one more folders in between the folder you just created inside(i.e. holiday) of webapps.

WEN-INFNow in WEB-INF folder we create another folder which

name most be Classes keep all XML file which will help us to connect the java file(i.e x.class) which are inside of Classes folder

NextLast

Page 29: Http, server & client communication

Continued….

In Classes folder all java compiled Servlet files will be stored. We can create our own package inside of Classes folder.

NextLast

WebAppDirectory WEB-INF

Classes

Some packages

Page 30: Http, server & client communication

Full tree structure of deployment directory

NextLast

WebAppDirectory

WEB-INF

Classes

Some packages

Lib

tlds

META-INF MANIFEST.MF

Page 31: Http, server & client communication

NextLast

JSPLet’s move to