1. Trang chủ
  2. » Công Nghệ Thông Tin

Head First Servlets and JSP phần 1 pps

75 261 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 75
Dung lượng 19,97 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

A single server supports tion is port 80 is the def ault, and as luck ault Server : The unique name of the physical server youÕre looking for.. Because mos t of the early servers on

Trang 2

ALREADY THIS 9OU THESE CHAPTER

&RYHUDJH1RWHV

Copyright Safari Books Online #747221

Trang 3

to build a web application that cli ents around the globe can access And t o become obscenely rich

6HUYHU

6HUYHU

Trang 4

The serverÕs response contains the actual document that the cli ent requested (or an error code if the request could not be proc

it can send to cli ents

That content can be web pages, JPEGs, and other resources.

Trang 7

DElNE A

CENTER

DElNE THE

DElNE DElNE DElNES

A THE

(Technically, the <center> and <a lign> tags have been deprecated in HTML 4.0, but weÕr e using them in some of our examples because i tÕs simpler to read than the alterna tive, and youÕre not here to learn HTML anyway.)

Trang 8

we want it (Remember,

<align> is depreca ted, but weÕre using it because i tÕs simple to read.)

in the form.

?PI\aW]_ZQ\M

\PM0<54

The <br> tags cause line breaks

An HTML comment

<RXQHHGRQO\WKHPRVWEDVLF+70/

NQRZOHGJH

(4-,NOT(4-,THOUGH HAPPENING

ZULWLQJ+70/

Trang 11

\RXDUHKHUH 

0<54Q[XIZ\WN\PM0<<8ZM[XWV[M

!NINFORMATIONOTHERBROWSEROF

When the browser Þ nds the opening <html> tag it goes into HTML-rendering mode and displays the page to the user.

Trang 15

\RXDUHKHUH 

)VI\WUaWNIV0<<8/-<ZMY]M[\

*(7VHOHFWVHOHFW%HHU7DVWHMVS"FRORU GDUN WDVWH PDOW\+773

+RVWZZZZLFNHGO\VPDUWFRP8VHU$JHQW0R]LOOD 0DFLQWRVK833&0DF26;0DFK2HQ86UY *HFNR

1HWVFDSH

$FFHSWWH[W[PODSSOLFDWLRQ[PODSSOLFDWLRQ[KWPO[POWH[WKWPOT WH[W

$FFHSW/DQJXDJHHQXVHQT 

$FFHSW(QFRGLQJJ]LSGHӿDWH.HHS$OLYH

The path to the resource on the web server that the web browser The protocol version

is requesting.

The Request headers.

Trang 16

 FKDSWHU

3267DGYLVRUVHOHFW%HHU7DVWHGR+773

+RVWZZZZLFNHGO\VPDUWFRP8VHU$JHQW0R]LOOD 0DFLQWRVK833&0DF26;0DFK2HQ86UY *HFNR

1HWVFDSH

$FFHSWWH[W[PODSSOLFDWLRQ[PODSSOLFDWLRQ[KWPO[POWH[WKWPOT WH[W

$FFHSW/DQJXDJHHQXVHQT 

$FFHSW(QFRGLQJJ]LSGHӿDWH.HHS$OLYH

The HTTP Method on the web serv The path to the r esource

er.

The protocol v ersion that the web browser is reques ting.

The message body,

This time, the parameter

s are down here

in the body, so they arenÕt limited the way they are if you use a GET and hav

Trang 17

\RXDUHKHUH 

)VI\WUaWNIV0<<8ZM[XWV[MIVL

_PI\\PMPMKSQ[I¹515-\aXMº'

the status code.

Notice that the MIME type value relates to the values listed in the HTTP requestÕs ÒAcceptÓ header

(Go look at the Accept header from the previous pageÕs POST request.)

Trang 18

to the browser.

And generates an HTTP response.

The server Þ nds the page

The HTTP GET is sent t o the serv

er.

The browser creates an HTTP GET request.

The browser renders the HTML.

*MMZP\UT

The user types a URL.

*(7WHVW%HHUKWPO+773

+RVWZZZZLFNHGO\VPDUWFRP8VHU$JHQW0R]LOOD 0DFLQWRVK

UHTXHVWDQGUHVSRQVH

KWWSZZZZLFNHGO\VPDUWFRPWHVW%HHUKWPO

Trang 20

optional A single serv

er supports

tion is

port 80 is the def

ault, and as luck

ault

Server : 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.

Path : The path to the location,

on the server, of the resourc e being requested Because mos t of the early servers on the web ran Unix, Unix syntax is still used t o describe the directory hierarchi es

on the web server.

Protocol: Tells the

server which communications

protocol (in this case

HTTP) will be used.

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.

DQDWRP\RID85/

Optional Query Str ing

: Remember, if this was a GET request, the ex

tra info (parameters) would be app

ended

to the end of this URL, s

tarting with a question mark Ò?Ó, and wi

th each parameter (name/v

alue pair) separated by an amp

ersand Ò Ó.

Not shown:

Trang 21

HTTP HTTPS

SRUWVIRU\RXURZQ

FXVWRPVHUYHUSURJUDPV

Using one server app per port, a server can have up to 65536 different server apps running (although itÕs possible to run more than one app on the same port if the apps use different protocols).

Trang 22

EHHU$GYLFH VNLLQJ$GYLFH

KWGRFV

$SDFKHBKRPH

FKHFNRXW

,QGH[KWPO ,QGH[KWPO

Òindex.htmlÓ is the default

page that will be returned

to a user who keys

Òwww.wickedlysmart.com/Ó

into his browser.

The root folder

application.

An Apache server will assume that ÒhtdocsÓ is the directory that is the root for all of the serverÕs web applications.

The two applications on this server.

The folders for the beerAdvice appÕs two actions.

Òindex.htmlÓ is the default page for the

that gives the user some advice.

Trang 24

These pages go straight

to the client just exactly as they were put on the server.

Trang 28

 FKDSWHU

;MZ^TM\[IVL+/1JW\PXTIa\PMZWTMWNI

PMTXMZIXXQV\PM_MJ[MZ^MZ

,ISTENPROS

0ERFORMANCE TOREQUEST

!H REQUESTSSEPARATENOAND

)SERVERSSPECIALPROGRAMS

INA

)CLIENTCONTAINERRIGHT

TO

WZRVLGHV&*,DQG6HUYOHWV

Trang 29

+RVWZZZZLFNHGO\VPDUWFRP8VHU$JHQW0R]LOOD 0DFLQWRVK

KWWSZZZZLFNHGO\VPDUWFRPWHVW%HHUKWPO5HTXHVW

Trang 30

Highlights:

-One DD per web applica tion.

-A DD can declare man y servlets.

- A <servlet-name> ti es the

<servlet> element to the mapping> element.

<servlet A <servlet<servlet class> is the Jav a class.

- A <url-pattern> is the name the client uses for the reques t.

Trang 31

(This is all one command.)

Trang 32

int

tream (itÕs really part of the HTTP r

GOOD

PAGEEASIERAND

%XCEPT

2EMEMBER ONE ABOUT

+70/LQDSULQWOQ VXFNV

Trang 37

9OU THESE CHAPTER

%NJOY WHILE

"54

MOVING EXPERIENCE PAGES MOVE

&RYHUDJH1RWHV

Copyright Safari Books Online #747221

Trang 39

ING MENT

Trang 40

LOGICFROM

AUTOMATICALLYREQUESTTHETHREADOFFSYNCHRONIZATIONMANAGEOF

7ELL ...

ZULWLQJ+70/

Trang 11

\RXDUHKHUH 

0<54Q[XIZ\WN\PM0<<8ZM[XWV[M... header from the previous pageÕs POST request.)

Trang 18

to the browser.

And. .. requesting.

The Request headers.

Trang 16

 FKDSWHU

3267DGYLVRUVHOHFW%HHU7DVWHGR+773

Ngày đăng: 12/08/2014, 19:20

TỪ KHÓA LIÊN QUAN