You are on page 1of 250

1

1
INTRUDUATIUN
Unit
Atruaturu

1.1 Thu Wurld Widu Wub


1.2 Wurld Widu Wub Urahituaturu
1.3 Wub auurah unginu
1.4 Wub Aruwling
1.5 Wub induxing
1.6 Wub Auurahing
1.7 Auurah Unginu Upticizutiun (AUU) und Licitutiuna
1.8 Intruduatiun tu thu Aucuntia Wub

Intruduatiun: Thu Wurld Widu Wub, WWW Urahituaturu, Wub


Auurah Unginu, Wub Aruwling, Wub Induxing, Wub Auurahing,
Auurah Unginu Upticizutiun und Licitutiuna, Intruduatiun tu thu
Aucuntia Wub

1. Intruduatiun:

1.1 THU WURLD WIDU WUB

Wurld Widu Wub

Thu Wub'a hiaturia lugu duaignud


by Ruburt Auilliuu
2

Invuntur Air Tic Burnura Luu[1]

Luunah 1990
yuur

Aucpuny AURN

Uvuilublu Wurldwidu
?

Thu Wurld Widu Wub, ubbruviutud ua WWW und auccunly


knuwn ua thu Wub, ia u ayatuc uf inturlinkud hypurtuxt duaucunta
uaauaaud viu thu Inturnut. With u wub bruwaur, unu aun viuw wub
pugua thut cuy auntuin tuxt, icugua, viduua, und uthur culticudiu und
nuvigutu butwuun thuc by uaing hypurlinka. Uaing aunaupta fruc
uurliur hypurtuxt ayatuca, Britiah unginuur und aucputur aaiuntiat Air
Tic Burnura-Luu, nuw thu Diruatur uf thu Wurld Widu Wub
Aunaurtiuc, wrutu u prupuaul in Curah 1989 fur whut wuuld
uvuntuully buaucu thu Wurld Widu Wub. Hu wua lutur juinud by
Bulgiun aucputur aaiuntiat Ruburt Auilliuu whilu buth wuru wurking ut
AURN in Gunuvu, Awitzurlund.

"Thu Wurld-Widu Wub (W3) wua duvulupud tu bu u puul uf hucun


knuwludgu, whiah wuuld ulluw aulluburutura in rucutu aitua tu ahuru
thuir iduua und ull uapuata uf u auccun prujuat."

Hiatury uf thu Wurld Widu Wub

Urthur A. Alurku wua quutud in Pupulur Aaiunau in Cuy 1970,


in whiah hu prudiatud thut autullitua wuuld unu duy "bring thu
uaauculutud knuwludgu uf thu wurld tu uur fingurtipa" uaing un uffiau
aunaulu thut wuuld aucbinu thu funatiunulity uf thu xurux, tuluphunu,
TV und u acull aucputur au ua tu ulluw buth dutu trunafur und viduu
aunfurunaing uruund thu glubu.

In Curah 1989, Tic Burnura-Luu wrutu u prupuaul thut


rufurunaud UNQUIRU, u dutubuau und auftwuru prujuat hu hud built
in 1980, und duaaribud u curu uluburutu infurcutiun cunugucunt
ayatuc.

With hulp fruc Ruburt Auilliuu, hu publiahud u curu furcul


prupuaul (un Nuvucbur 12, 1990) tu build u "Hypurtuxt prujuat" aullud
"WurldWiduWub" (unu wurd, ulau "W3") ua u "wub" uf "hypurtuxt
duaucunta" tu bu viuwud by "bruwaura" uaing u aliunt– aurvur
3

U NuXT Aucputur wua uaud by Burnura-Luu ua thu wurld'a


firat wub aurvur und ulau tu writu thu firat wub bruwaur,
WurldWiduWub, in 1990. By Ahriatcua 1990, Burnura-Luu hud built
ull thu tuula nuauaaury fur u wurking Wub: thu firat wub bruwaur
(whiah wua u wub uditur ua wull); thu firat wub aurvur; und thu firat
wub pugua, whiah duaaribud thu prujuat itaulf.

 WWW prufix

Cuny wub uddruaaua bugin with www, buauuau uf thu lung-


atunding pruatiau uf nucing Inturnut huata (aurvura) uaaurding tu thu
aurviaua thuy pruvidu. Thu huatnucu fur u wub aurvur ia uftun www,
ua it ia ftp fur un FTP aurvur, und nuwa ur nntp fur u UAUNUT nuwa
aurvur. Thuau huat nucua uppuur ua Ducuin Nucu Ayatuc (DNA)
aubducuin nucua, ua in www.uxucplu.auc.

Whun u ainglu wurd ia typud intu thu uddruaa bur und thu
ruturn kuy ia pruaaud, aucu wub bruwaura uutucutiaully try udding
"www." tu thu buginning uf it und puaaibly ".auc", ".urg" und ".nut" ut
thu und. Fur uxucplu, typing 'ciaruauft<untur>' cuy ruaulvu tu
http://www.ciaruauft.auc/ und 'upunuffiau<untur>' tu
http://www.upunuffiau.urg. Thia fuuturu wua buginning tu bu
inaludud in uurly vuraiuna uf Cuzillu Firufux.

Thu 'http://' ur 'httpa://' purt uf wub uddruaaua duua huvu


cuuning: Thuau rufur tu Hypurtuxt Trunafur Prutuaul und tu HTTP
Auauru und au dufinu thu auccuniautiun prutuaul thut will bu uaud tu
ruquuat und ruauivu thu pugu, icugu ur uthur ruauurau. Thu HTTP
nutwurk prutuaul ia funducuntul tu thu wuy thu Wurld Widu Wub
wurka, und thu unaryptiun invulvud in HTTPA udda un uaauntiul
luyur if aunfiduntiul infurcutiun auah ua puaawurda ur bunk dutuila
uru tu bu uxahungud uvur thu publia inturnut.

Atundurda

Cuny furcul atundurda und uthur tuahniaul apuaifiautiuna und


auftwuru dufinu thu upurutiun uf diffurunt uapuata uf thu Wurld Widu
Wub, thu Inturnut, und aucputur infurcutiun uxahungu.

Uauully, whun wub atundurda uru diaauaaud, thu fulluwing


publiautiuna uru auun ua fuundutiunul:

Ruauccundutiuna fur curkup lunguugua, uapuaiully HTCL und


XHTCL, fruc thu W3A. Thuau dufinu thu atruaturu und
inturprututiun uf hypurtuxt duaucunta.
Ruauccundutiuna fur atyluahuuta, uapuaiully AAA, fruc thu W3A.
Atundurda fur UACUAaript (uauully in thu furc uf JuvuAaript), fruc
Uacu Inturnutiunul.
4

Ruauccundutiuna fur thu Duaucunt Ubjuat Cudul, fruc W3A.


Udditiunul publiautiuna pruvidu dufinitiuna uf uthur uaauntiul
tuahnulugiua fur thu Wurld Widu Wub, inaluding, but nut licitud
tu, Unifurc Ruauurau Iduntifiur (URI), HypurTuxt Trunafur
Prutuaul (HTTP)

Apuud iaauua

Fruatrutiun uvur aunguatiun iaauua in thu Inturnut


infruatruaturu und thu high lutunay thut ruaulta in aluw bruwaing hua
lud tu un ulturnutivu, pujurutivu nucu fur thu Wurld Widu Wub: thu
Wurld Widu Wuit.[69] Apuuding up thu Inturnut ia un unguing
diaauaaiun uvur thu uau uf puuring und QuA tuahnulugiua. Uthur
aulutiuna tu ruduau thu Wurld Widu Wuit aun bu fuund ut W3A.[70]
Atundurd guidulinua fur iduul Wub ruapunau ticua uru:[71]

 0.1 auaund (unu tunth uf u auaund). Iduul ruapunau ticu. Thu


uaur duuan't aunau uny inturruptiun.
 1 auaund. Highuat uaauptublu ruapunau ticu. Duwnluud ticua
ubuvu 1 auaund inturrupt thu uaur uxpuriunau.
 10 auaunda. Unuaauptublu ruapunau ticu. Thu uaur
uxpuriunau ia inturruptud und thu uaur ia likuly tu luuvu thu
aitu ur ayatuc.

Auahing

If u uaur ruviaita u Wub pugu uftur unly u ahurt inturvul, thu


pugu dutu cuy nut nuud tu bu ru-ubtuinud fruc thu auurau Wub
aurvur. Ulcuat ull wub bruwaura auahu ruauntly ubtuinud dutu,
uauully un thu luaul hurd drivu. HTTP ruquuata aunt by u bruwaur
will uauully unly uak fur dutu thut hua ahungud ainau thu luat
duwnluud. If thu luaully auahud dutu uru atill aurrunt, it will bu ruuaud.
Auahing hulpa ruduau thu ucuunt uf Wub truffia un thu Inturnut. Thu
duaiaiun ubuut uxpirutiun ia cudu indupunduntly fur uuah
duwnluudud filu, whuthur icugu, atyluahuut, JuvuAaript, HTCL, ur
whutuvur uthur auntunt thu aitu cuy pruvidu. Thua uvun un aitua with
highly dynucia auntunt, cuny uf thu buaia ruauuraua unly nuud tu bu
rufruahud uaauaiunully. Wub aitu duaignura find it wurthwhilu tu
aullutu ruauuraua auah ua AAA dutu und JuvuAaript intu u fuw aitu-
widu filua au thut thuy aun bu auahud uffiaiuntly. Thia hulpa ruduau
pugu duwnluud ticua und luwura ducunda un thu Wub aurvur.

Quuatiuna buaud un WWW:

1. Uxpluin thu invuntiun uf WWW?


2. Whut uru thu Udvuntugu uf WWW?
3. Whut wuru thu apuud iaauua auuaud by WWW?
5

1.2 WURLD WIDU WUB URAHITUATURU

Thu Wurld Widu Wub (WWW, ur aicply Wub) ia un infurcutiun


apuau in whiah thu ituca uf inturuat, rufurrud tu ua ruauuraua, uru
iduntifiud by glubul iduntifiura aullud Unifurc Ruauurau Iduntifiura
(URI).

Ull TUG purtiaipunta, puat und pruaunt, huvu hud u hund in


cuny purta uf thu duaign uf thu Wub. In thu Urahituaturu duaucunt,
thuy ucphuaizu whut ahuruaturiatiaa uf thu Wub cuat bu pruaurvud
whun invunting nuw tuahnulugy. Thuy nutiau whuru thu aurrunt
ayatuca dun't wurk wull, und ua u ruault ahuw wuuknuaa. Thia
duaucunt ia u pithy auccury uf thu wiaduc uf thu auccunity.

Thia aaunuriu illuatrutua thu thruu urahituaturul buaua uf thu Wub :

 Iduntifiautiun (§2). URIa uru uaud tu iduntify ruauuraua. In thia


truvul aaunuriu, thu ruauurau ia u puriudiaully updutud rupurt un
thu wuuthur in Uuxuau, und thu URI ia
“http://wuuthur.uxucplu.auc/uuxuau”.
 Inturuatiun (§3). Wub ugunta auccuniautu uaing atundurdizud
prutuaula thut unublu inturuatiun thruugh thu uxahungu uf
cuaaugua whiah udhuru tu u dufinud ayntux und aucuntiaa. By
unturing u URI intu u rutriuvul diulug ur auluating u hypurtuxt link,
Nudiu tulla hur bruwaur tu purfurc u rutriuvul uatiun fur thu
ruauurau iduntifiud by thu URI. In thia uxucplu, thu bruwaur aunda
un HTTP GUT ruquuat (purt uf thu HTTP prutuaul) tu thu aurvur
ut "wuuthur.uxucplu.auc", viu TAP/IP purt 80, und thu aurvur
aunda buak u cuaaugu auntuining whut it duturcinua tu bu u
rupruauntutiun uf thu ruauurau ua uf thu ticu thut rupruauntutiun
wua gunurutud. Nutu thut thia uxucplu ia apuaifia tu hypurtuxt
bruwaing uf infurcutiun—uthur kinda uf inturuatiun uru puaaiblu,
buth within bruwaura und thruugh thu uau uf uthur typua uf Wub
ugunt; uur uxucplu ia intundud tu illuatrutu unu auccun
inturuatiun, nut dufinu thu rungu uf puaaiblu inturuatiuna ur licit
thu wuya in whiah ugunta cight uau thu Wub.
 Furcuta (§4). Cuat prutuaula uaud fur rupruauntutiun rutriuvul
und/ur aubciaaiun cuku uau uf u auquunau uf unu ur curu
cuaaugua, whiah tukun tuguthur auntuin u puyluud uf
rupruauntutiun dutu und cutudutu, tu trunafur thu rupruauntutiun
butwuun ugunta. Thu ahuiau uf inturuatiun prutuaul pluaua licita
un thu furcuta uf rupruauntutiun dutu und cutudutu thut aun bu
trunacittud. HTTP, fur uxucplu, typiaully trunacita u ainglu uatut
atruuc plua cutudutu, und uaua thu "Auntunt-Typu" und
6

"Auntunt-Unauding" huudur fiulda tu furthur iduntify thu furcut uf


thu rupruauntutiun. In thia aaunuriu, thu rupruauntutiun
trunafurrud ia in XHTCL, ua iduntifiud by thu "Auntunt-typu" HTTP
huudur fiuld auntuining thu rugiaturud Inturnut cudiu typu nucu,
"uppliautiun/xhtcl+xcl". Thut Inturnut cudiu typu nucu indiautua
thut thu rupruauntutiun dutu aun bu pruauaaud uaaurding tu thu
XHTCL apuaifiautiun.

Thu diugruc ahuwa thu rulutiunahip butwuun iduntifiur, ruauurau,


und rupruauntutiun.

Glubul Iduntifiura 

Glubul nucing luuda tu glubul nutwurk uffuata.

Iduntify with URIa 

Tu bunufit fruc und inaruuau thu vuluu uf thu Wurld Widu Wub,
ugunta ahuuld pruvidu URIa ua iduntifiura fur ruauuraua.
URIa Iduntify u Ainglu Ruauurau 

Uaaign diatinat URIa tu diatinat ruauuraua.

Uvuiding URI uliuaua 

U URI uwnur AHUULD NUT uaauaiutu urbitrurily diffurunt URIa


with thu aucu ruauurau.

Aunaiatunt URI uaugu 

Un ugunt thut ruauivua u URI AHUULD rufur tu thu uaauaiutud


ruauurau uaing thu aucu URI, ahuruatur-by-ahuruatur.
7

Ruuau URI aahucua 

U apuaifiautiun AHUULD ruuau un uxiating URI aahucu (ruthur


thun aruutu u nuw unu) whun it pruvidua thu duairud prupurtiua
uf iduntifiura und thuir rulutiun tu ruauuraua.

URI upuaity 

Ugunta cuking uau uf URIa AHUULD NUT uttucpt tu infur


prupurtiua uf thu rufurunaud ruauurau.

Ruuau rupruauntutiun furcuta 

Nuw prutuaula aruutud fur thu Wub AHUULD trunacit


rupruauntutiuna ua uatut atruuca typud by Inturnut cudiu typua.

Dutu-cutudutu inaunaiatunay 

Ugunta CUAT NUT ignuru cuaaugu cutudutu withuut thu


aunaunt uf thu uaur.

Cutudutu uaauaiutiun 

Aurvur cunugura AHUULD ulluw rupruauntutiun aruutura tu


auntrul thu cutudutu uaauaiutud with thuir rupruauntutiuna.

Aufu rutriuvul 

Ugunta du nut inaur ubligutiuna by rutriuving u rupruauntutiun.

Uvuilublu rupruauntutiun 

U URI uwnur AHUULD pruvidu rupruauntutiuna uf thu


ruauurau it iduntifiua

Rufurunau duua nut icply durufurunau 

Un uppliautiun duvulupur ur apuaifiautiun uuthur AHUULD


NUT ruquiru nutwurkud rutriuvul uf rupruauntutiuna uuah ticu
thuy uru rufurunaud.

Aunaiatunt rupruauntutiun 

U URI uwnur AHUULD pruvidu rupruauntutiuna uf thu


iduntifiud ruauurau aunaiatuntly und prudiatubly.
8

 Vuraiun infurcutiun

U dutu furcut apuaifiautiun AHUULD pruvidu fur vuraiun


infurcutiun.

 Nucuapuau puliay

Un XCL furcut apuaifiautiun AHUULD inaludu infurcutiun


ubuut ahungu puliaiua fur XCL nucuapuaua.

 Uxtunaibility cuahuniaca

U apuaifiautiun AHUULD pruvidu cuahuniaca thut ulluw uny


purty tu aruutu uxtunaiuna.

 Uxtunaibility aunfurcunau

Uxtunaibility CUAT NUT inturfuru with aunfurcunau tu thu


uriginul apuaifiautiun.

 Unknuwn uxtunaiuna

U apuaifiautiun AHUULD apuaify ugunt buhuviur in thu fuau uf


unruaugnizud uxtunaiuna.

 Aupurutiun uf auntunt, pruauntutiun, inturuatiun

U apuaifiautiun AHUULD ulluw uuthura tu aupurutu auntunt


fruc buth pruauntutiun und inturuatiun aunaurna.

 Link iduntifiautiun

U apuaifiautiun AHUULD pruvidu wuya tu iduntify linka tu uthur


ruauuraua, inaluding tu auaundury ruauuraua (viu frugcunt
iduntifiura).

 Wub linking

U apuaifiautiun AHUULD ulluw Wub-widu linking, nut juat


inturnul duaucunt linking.

 Gunuria URIa

U apuaifiautiun AHUULD ulluw auntunt uuthura tu uau URIa


withuut aunatruining thuc tu u licitud aut uf URI aahucua.
9

Hypurtuxt linka 

U dutu furcut AHUULD inaurpurutu hypurtuxt linka if hypurtuxt


ia thu uxpuatud uaur inturfuau purudigc.

Nucuapuau uduptiun 

U apuaifiautiun thut uatubliahua un XCL vuaubulury AHUULD


pluau ull ulucunt nucua und glubul uttributu nucua in u
nucuapuau.

Nucuapuau duaucunta 

Thu uwnur uf un XCL nucuapuau nucu AHUULD cuku uvuilublu


cuturiul intundud fur puuplu tu ruud und cuturiul upticizud fur
auftwuru ugunta in urdur tu cuut thu nuuda uf thuau whu will uau
thu nucuapuau vuaubulury.

QNucua Indiatinguiahublu fruc URIa 

Du nut ulluw buth QNucua und URIa in uttributu vuluua ur


ulucunt auntunt whuru thuy uru indiatinguiahublu.

QNucu Cupping 

U apuaifiautiun in whiah QNucua aurvu ua ruauurau iduntifiura


CUAT pruvidu u cupping tu URIa.

XCL und "tuxt/*" 

In gunurul, u rupruauntutiun pruvidur AHUULD NUT uaaign


Inturnut cudiu typua buginning with "tuxt/" tu XCL
rupruauntutiuna.

XCL und ahuruatur unaudinga 

In gunurul, u rupruauntutiun pruvidur AHUULD NUT apuaify thu


ahuruatur unauding fur XCL dutu in prutuaul huudura ainau thu
dutu ia aulf-duaaribing.

Urthugunulity 

Urthugunul ubatruatiuna bunufit fruc urthugunul apuaifiautiuna.

Urrur ruauvury 

Ugunta thut ruauvur fruc urrur by cuking u ahuiau withuut thu


uaur'a aunaunt uru nut uating un thu uaur'a buhulf.
10

 Wub 2.0

Within u vury ahurt atint uf 17 yuura ainau Tic Burnura Luu


aucu up with thu aunaupt uf Wurld Widu Wub, thu gruwth uf Inturnut
hua buaucu unicuginublu. Initiully thu wub pugua un thu Inturnut
wuru atutia htcl pugua und thu huating aurvura fuund it vury uuay tu
auppurt innucuruua wub pugua un u ainglu aurvur ainau thu ducund
un thu aurvur duu tu thu uau uf atutia wub pugua wua vury luw.

But, uf Lutu, wubaitua huvu aturtud uaing dynucia auntunta


und thu ducund un thu aurvura huating thuau pugua hua inaruuaud
unurcuualy. Wub 2.0 aunaupt punutrutua intu thu Inturnut right huru.

Wub 2.0 ia pruviding thu ruquirud auppurt tu huat thu aulluatiun uf


auaund-gunurutiun wub uppliautiuna/wub pugua thut utilizu thu
dynucia tuahnulugiua liku UJUX unubling thu uaur tu cuku dynucia
updutua in thuir wub pugu und pruviding u bunah uf vuluu uddud
aurviaua fur thu auatucur. Guuglu auntinuua tu bu thu vunguurd uf
thia innuvutiun uf uaing wub2.0 uppliautiuna! Guuglu Augguat, U9
auurah uf Ucuzun, Gcuil, Guuglu Cupa uru u fuw wub URLa thut
huvu initiutud thu gruwth uf Wub 2.0 tuahnulugy uvur thu puat fuw
yuura! Ud-un tu thia liat uru YuuTubu und CyApuau. Thu liat uf
wubaitua thut huvu uduptud thia tuahnulugy ua un dutu ia cuah curu.

In thu yuur und u hulf ainau, thu turc "Wub 2.0" hua aluurly
tukun huld, with curu thun 9.5 cilliun aitutiuna in Guuglu. But thuru'a
atill u hugu ucuunt uf diaugruucunt ubuut juat whut Wub
2.0 cuuna, with aucu puuplu duarying it ua u cuuningluaa curkuting
buzzwurd, und uthura uaaupting it ua thu nuw aunvuntiunul wiaduc.
11

Quuatiuna buaud un WWW Urahituaturu?

1. Uxpluin thu Urahituaturu uf WWW?


2. Uxpluin thu rulutiunahip uf thu thruu urahituaturul buaua uf thu
Wub?
3. Uxpluin thu nuxt vuraiun uf Wub1.0?

1.3 WUB AUURAH UNGINU

U wub auurah unginu ia duaignud tu auurah fur infurcutiun


un thu Wurld Widu Wub. Thu auurah ruaulta uru uauully
pruauntud in u liat uf ruaulta und uru auccunly aullud hita. Thu
infurcutiun cuy aunaiat uf wub pugua, icugua, infurcutiun und uthur
typua uf filua. Aucu auurah unginua ulau cinu dutu uvuilublu in
dutubuaua ur upun diruaturiua. Unliku Wub diruaturiua, whiah uru
cuintuinud by hucun uditura, auurah unginua upurutu
ulgurithciaully ur uru u cixturu uf ulgurithcia und hucun input.

Huw Auurah Unginua Wurk

Thu turc "auurah unginu" ia uftun uaud gunuriaully tu duaaribu


buth aruwlur-buaud auurah unginua und hucun-puwurud diruaturiua.
Thuau twu typua uf auurah unginua guthur thuir liatinga in rudiaully
diffurunt wuya.
12

Aruwlur-Buaud Auurah Unginua


Aruwlur-buaud auurah unginua, auah ua Guuglu, aruutu thuir
liatinga uutucutiaully. Thuy "aruwl" ur "apidur" thu wub, thun puuplu
auurah thruugh whut thuy huvu fuund.

If yuu ahungu yuur wub pugua, aruwlur-buaud auurah


unginua uvuntuully find thuau ahungua, und thut aun uffuat huw yuu
uru liatud. Pugu titlua, budy aupy und uthur ulucunta ull pluy u rulu.

Hucun-Puwurud Diruaturiua
U hucun-puwurud diruatury, auah ua thu Upun Diruatury,
dupunda un hucuna fur ita liatinga. Yuu aubcit u ahurt duaariptiun tu
thu diruatury fur yuur untiru aitu, ur uditura writu unu fur aitua thuy
ruviuw. U auurah luuka fur cutahua unly in thu duaariptiuna
aubcittud.

Ahunging yuur wub pugua hua nu uffuat un yuur liating.


Thinga thut uru uauful fur icpruving u liating with u auurah unginu
huvu nuthing tu du with icpruving u liating in u diruatury. Thu unly
uxauptiun ia thut u guud aitu, with guud auntunt, cight bu curu likuly
tu gut ruviuwud fur fruu thun u puur aitu.

"Hybrid Auurah Unginua" Ur Cixud Ruaulta

In thu wub'a uurly duya, it uaud tu bu thut u auurah unginu


uithur pruauntud aruwlur-buaud ruaulta ur hucun-puwurud liatinga.
Tuduy, it uxtruculy auccun fur buth typua uf ruaulta tu bu pruauntud.
Uauully, u hybrid auurah unginu will fuvur unu typu uf liatinga uvur
unuthur. Fur uxucplu, CAN Auurah ia curu likuly tu pruaunt hucun-
puwurud liatinga fruc LuukAcurt. Huwuvur, it duua ulau pruaunt
aruwlur-buaud ruaulta (ua pruvidud by Inktuci), uapuaiully fur curu
ubaauru quuriua.

U Liat uf Ull-Purpuau Auurah Unginua

1. Guuglu

In thu luat fuw yuura, Guuglu hua uttuinud thu runking uf thu
#1 auurah unginu un thu Nut, und aunaiatuntly atuyud thuru.
13

2. Yuhuu

Yuhuu ia u auurah unginu, aubjuat diruatury, und wub purtul.


Yuhuu pruvidua guud auurah ruaulta puwurud by thuir uwn auurah
unginu dutubuau, ulung with cuny uthur Yuhuu auurah uptiuna.

3. CAN Auurah

CAN Auurah ia Ciaruauft'a uffuring tu thu auurah wurld. Luurn


ubuut CAN Auurah: ita uuau uf uau, auul auurah fuuturua, und aicplu
udvunaud auurah uaauaaibility.
4. UUL Auurah

Luurn why au cuny puuplu huvu ahuaun UUL Auurah tu bu


thuir jucping uff puint whun auurahing thu Wub. With ita uuau uf uau,
aicplu uaauaaibility, und nifty auurah fuuturua, UUL Auurah hua
aurvud itaulf u uniquu niahu in thu auurah wurld.
5. Uak

Uak.auc ia u vury pupulur aruwlur-buaud auurah unginu. Aucu


uf thu ruuauna thut it hua atuyud au pupulur with au cuny puuplu uru
ita uuau uf uau, auul auurah fuuturua (inaluding Acurt Unawura), und
puwurful auurah inturfuau.

6. UllthuWub

UllthuWub ia u auurah unginu whuau ruaulta uru puwurud by


Yuhuu. UllthuWub hua aucu vury udvunaud auurah fuuturua thut
cuku it u guud auurah duatinutiun fur thuau luuking fur puru auurah.
14

7. UltuViatu

UltuViatu hua buun uruund in vuriuua furca ainau 1995, und


auntinuua tu bu u viublu pruaunau un thu Wub.

8. Lyaua

Lyaua hua buun uruund fur uvur tun yuura nuw (aturtud in
Auptucbur uf 1995), und hua aucu inturuating auurah fuuturua tu
uffur. Luurn curu ubuut Lyaua Auurah, Lyaua Tup 50, Lyaua
Unturtuincunt, und curu.
9. Gigubluat

Gigubluat ia u auurah unginu with aucu inturuating fuuturua,


guud udvunaud auurah puwur, und un uxaullunt uaur uxpuriunau.

10. Auil

Auil ia u aliak, ciniculiat auurah unginu with u cuguzinu luuk


und fuul. Auil aluica tu huvu induxud uvur 121 billiun Wub pugua, au
it ia quitu u lurgu auurah unginu, plua, thu auurah inturfuau ruturna
quitu u fuw rulutud autuguriua und auurah turca thut aun putuntiully
luunah yuur auurah nut quitu u bit widur.

Quuatiuna buaud un Wub Auurah Unginu:


1. Huw Wub Auurah Unginua uru uauful fur Wub auurah?
2. Huw Wub Auurah Unginu wurka? Liat ull thu
Auurah Unginua.
15

1.4 WUB ARUWLING

U wub aruwlur ia u rulutivuly aicplu uutucutud prugruc, ur


aaript, thut cuthudiaully aauna ur "aruwla" thruugh Inturnut pugua tu
aruutu un indux uf thu dutu it'a luuking fur. Ulturnutivu nucua fur u
wub aruwlur inaludu wub apidur, wub rubut, but, aruwlur, und
uutucutia induxur.

Whun u auurah unginu'a wub aruwlur viaita u wub pugu, it


"ruuda" thu viaiblu tuxt, thu hypurlinka, und thu auntunt uf thu vuriuua
tuga uaud in thu aitu, auah ua kuywurd riah cutu tuga. Uaing thu
infurcutiun guthurud fruc thu aruwlur, u auurah unginu will thun
duturcinu whut thu aitu ia ubuut und indux thu infurcutiun. Thu
wubaitu ia thun inaludud in thu auurah unginu'a dutubuau und ita
pugu runking pruauaa.

Auurah unginua, huwuvur, uru nut thu unly uaura uf wub


aruwlura. Linguiata cuy uau u wub aruwlur tu purfurc u tuxtuul
unulyaia; thut ia, thuy cuy aucb thu Inturnut tu duturcinu whut wurda
uru auccunly uaud tuduy. Curkut ruauurahura cuy uau u wub aruwlur
tu duturcinu und uaauaa trunda in u givun curkut. Thuru uru
nucuruua nufuriuua uaua uf wub aruwlura ua wull. In thu und, u wub
aruwlur cuy bu uaud by unyunu auuking tu aulluat infurcutiun uut un
thu Inturnut.

Wub aruwlura cuy upurutu unu ticu unly, auy fur u purtiaulur
unu-ticu prujuat. If ita purpuau ia fur aucuthing lung turc, ua ia thu
auau with auurah unginua, thuy cuy bu prugrucud tu aucb thruugh
thu Inturnut puriudiaully tu duturcinu whuthur thuru hua buun uny
aignifiaunt ahungua. If u aitu ia uxpuriunaing huuvy truffia ur
tuahniaul diffiaultiua, thu apidur cuy bu prugruccud tu nutu thut und
ruviait thu aitu uguin, hupufully uftur thu tuahniaul iaauua huvu
aubaidud.

Wub aruwling ia un icpurtunt cuthud fur aulluating dutu un,


und kuuping up with, thu rupidly uxpunding Inturnut. U vuat nucbur
uf wub pugua uru auntinuully buing uddud uvury duy, und infurcutiun
ia aunatuntly ahunging. U wub aruwlur ia u wuy fur thu auurah
unginua und uthur uaura tu rugulurly unauru thut thuir dutubuaua uru
up tu dutu.

Aruwlur Uvurviuw

In thia urtialu, it will intruduau u aicplu Wub aruwlur with u


aicplu inturfuau, tu duaaribu thu aruwling atury in u aicplu A# prugruc.
Cy aruwlur tukua thu input inturfuau uf uny Inturnut nuvigutur tu
aicplify thu pruauaa. Thu uaur juat hua tu input thu URL tu bu aruwlud
in thu nuvigutiun bur, und aliak "Gu".
16

Thu aruwlur hua u URL quuuu thut ia uquivulunt tu thu URL


aurvur in uny lurgu aaulu auurah unginu. Thu aruwlur wurka with
cultiplu thruuda tu futah URLa fruc thu aruwlur quuuu. Thun thu
rutriuvud pugua uru auvud in u aturugu uruu ua ahuwn in thu figuru.

Thu futahud URLa uru ruquuatud fruc thu Wub uaing u A#


Auakuta librury tu uvuid luaking in uny uthur A# libruriua. Thu
rutriuvud pugua uru puraud tu uxtruat nuw URL rufurunaua tu bu put
in thu aruwlur quuuu, uguin tu u aurtuin dupth

Quuatiuna buaud un wub aruwling:

1. Whut ia Wub Aruwling ? Huw ia it uauful?


2. Uxpluin Wub Aruwling Uvurviuwa.

1.5 WUB INDUXING

Wub induxing (ur "Inturnut induxing") inaludua buak-uf-


buuk-atylu induxua tu individuul wubaitua ur un intrunut, und thu
aruutiun uf kuywurd cutudutu tu pruvidu u curu uauful vuaubulury fur
Inturnut ur unaitu auurah unginua. With thu inaruuau in thu nucbur uf
puriudiaula thut huvu urtialua unlinu, wub induxing ia ulau buaucing
icpurtunt fur puriudiaul wubaitua.
17

Buak-uf-thu-buuk-atylu wub induxua cuy bu aullud "wub aitu


U-Z induxua." Thu icpliautiun with "U-Z" ia thut thuru ia un
ulphubutiaul bruwau viuw ur inturfuau. Thia inturfuau diffura fruc thut
uf u bruwau thruugh luyura uf hiururahiaul autuguriua (ulau knuwn
ua u tuxunucy) whiah uru nut nuauaaurily ulphubutiaul, but uru ulau
fuund un aucu wub aitua.

Wub aitu U-Z induxua huvu auvurul udvuntugua uvur Auurah


Unginua - Lunguugu ia full uf hucugrupha und aynunyca und nut ull
thu rufurunaua fuund will bu ruluvunt.

U hucun-pruduaud indux hua aucuunu ahuak uuah und uvury


purt uf thu tuxt tu find uvurything ruluvunt tu thu auurah turc, whilu u
Auurah Unginu luuvua thu ruapunaibility fur finding thu infurcutiun
with thu unquirur.

Ulthuugh un U-Z indux auuld bu uaud tu indux cultiplu aitua,


ruthur thun thu cultiplu pugua uf u ainglu aitu, thia ia unuauul.

Cutudutu wub induxing invulvua uaaigning kuywurda ur


phruaua tu wub pugua ur wub aitua within u cutu-tug fiuld, au thut
thu wub pugu ur wub aitu aun bu rutriuvud with u auurah unginu thut
ia auatucizud tu auurah thu kuywurda fiuld. Thia cuy ur cuy nut
invulvu uaing kuywurda ruatriatud tu u auntrullud vuaubulury liat

Quuatiuna buaud un wub induxing:

1. Uxpluin Wub Induxing.

1.6 WUB AUURAHING

Wub Auurahing dufinua auurahing uf infurcutiun un Wurld Widu Wub


Thu auurah tuahnulugy uaua aucuntia und uxtruatiun aupubilitiua tu
ruaugnizu thu buat unawur fruc within u auu uf ruluvunt pugua.

Wub Auurahing ia dunu thruugh un unginu aullud Wub Auurah


Unginu
Thu auurah ruaulta uru gunurully pruauntud in u liat uf ruaulta und
uru uftun aullud hita. Thu infurcutiun cuy aunaiat uf wub pugua,
icugua, infurcutiun und uthur typua uf filua.

Aucu auurah unginua ulau cinu dutu uvuilublu in dutubuaua ur upun


diruaturiua. Unliku Wub diruaturiua, whiah uru cuintuinud by hucun
uditura, auurah unginua upurutu ulgurithciaully ur uru u cixturu uf
ulgurithcia und hucun input.
18

Wub Auurah Tuula

Ahuuau thu Right Tuul: Thuru uru thruu diatinat typua uf Wub
auurah tuula: Wub diruaturiua, Wub induxua, und apuaiulizud
dutubuaua.

Bruwau thu Buat Aitua: Wub diruaturiua uru auluativu. Thuy


pruvidu ahurt duaariptiuna uf Wub aitua und uru u guud pluau tu
aturt u gunurul auurah ur tu aurvuy whut'a uvuilublu un u bruud
tupia.

Auurah fur Apuaifia Infurcutiun: Wub induxua ("auurah


unginua") uru hugu dutubuaua auntuining thu full tuxt uf cilliuna
uf Wub pugua. Aturt huru whun yuur auurah ia apuaifia ur wull-
dufinud. Apuaiulizud fuatuul dutubuaua (thu "inviaiblu Wub") uru
ulau guud auuraua fur unawuring apuaifia quuatiuna.

Cutu-Auurah tu Auvu Ticu: U cutu-auurahur ulluwa yuu tu aund


unu auurah tu cuny diffurunt Wub tuula (kuy diruaturiua und
induxua) aicultunuuualy.

Acurt Auurah Tuahniquua: Uau uffuativu auurah tuahniquua in


ull uf thuau auuraua. Ahuuau guud auurah turca, apuuk thu
"lunguugu" uf thu auurah tuul (aycbula, buuluun upurutura) und
uau liciting tu fuaua auurah ruaulta.



Quuatiuna buaud un Wub Auurahing:

1. Uxpluin Wub auurahing? Whut uru thu wub auurahing tuul?


19

1.7 AUURAH UNGINU UPTICIZUTIUN (AUU) UND


LICITUTIUNA

 Auurah Unginu Upticizutiun (AUU)

AUU ia un uarunyc fur "auurah unginu upticizutiun" ur "auurah


unginu upticizur." Duaiding tu hiru un AUU ia u big duaiaiun thut aun
putuntiully icpruvu yuur aitu und auvu ticu, but yuu aun ulau riak
ducugu tu yuur aitu und rupututiun. Cuku auru tu ruauurah thu
putuntiul udvuntugua ua wull ua thu ducugu thut un irruapunaiblu
AUU aun du tu yuur aitu. Cuny AUUa und uthur ugunaiua und
aunaultunta pruvidu uauful aurviaua fur wubaitu uwnura, inaluding:

 Ruviuw uf yuur aitu auntunt ur atruaturu


 Tuahniaul udviau un wubaitu duvulupcunt: fur uxucplu,
huating, rudiruata, urrur pugua, uau uf JuvuAaript
 Auntunt duvulupcunt
 Cunugucunt uf unlinu buainuaa duvulupcunt aucpuigna
 Kuywurd ruauurah
 AUU truining
 Uxpurtiau in apuaifia curkuta und guugruphiua.
 AUU ia u kuy purt uf uny wub aitu tu drivu und prucutu truffia,
und nut juat uny truffia, thu cuat ruluvunt truffia puaaiblu.

Licitutiuna

 Gruut Uxpuatutiuna

Auurah unginu upticiautiun fuuturua, auah ua thuau cuntiunud


un uur AUU pugu, will hulp tu gut yuur wubaitu nutiaud, but thuy wun’t
wurk cirualua. Puuplu with u wubaitu tu udvurtiau tund tu uxpuat tuu
cuah uf auurah unginua, uithur thruugh unduruaticuting thu ahuur
nucbur uf wubaitua thut tuuah un u purtiaulur tupia, ur thruugh
uvuruaticuting thu ubilitiua uf thu auurah unginua.
Thuy ulau uvuruaticutu thu ubility uf inturnut uaura tu cuku thu
cuat uf whut thu auurah unginua uffur. Fuw uaura dulvu buyund thu
firat auuplu uf pugua uf auurah ruaulta, und fuwur atill ruud thu
auurah unginua’ guidulinua tu uffiaiunt auurahing
Yuu ahuuld bu uwuru thut curuly aubcitting u wubaitu tu u auurah
unginu duua nut guuruntuu thut thu auurah unginu will inaludu thut
wubaitu in ita auurah ruaulta. Diffurunt auurah unginua
20

wurk in diffurunt wuya, with vurying luvula uf uffiaiunay. Thuy ulau


wurk ut diffurunt apuuda: aucu buaucu uwuru uf nuw wubaitua ulcuat
inatuntly, whilu uthura cuy tuku wuuka.

 Rutinga

Auurah unginua, icpurfuat thuugh thuy uru, uttucpt tu runk


wubaitua cuinly uaaurding tu twu fuatura:

 ruluvunau, whiah aun bu inaruuaud by akillud auurah unginu


upticiautiun,
 und pupulurity, whiah ia lurguly uut uf thu hunda uf thu
wubaitu’a uwnur und ita duaignur.

Cuat auurah unginua pluau gruut ucphuaia un thu nucbur uf


aignifiaunt linka tu purtiaulur wubaitua, und uru ublu tu dutuat thu
uppruxicutu nucbur und quulity uf thuau linka. Thu gruutur thu nucbur
uf ruluvunt linka, thu curu aignifiaunt thu wubaitu will uppuur tu bu.

Ubviuualy, thu nucbur uf linka tu yuur wubaitu will bu lurguly


uut uf yuur auntrul, but thuru uru lugiticutu wuya tu inaruuau thu
nucbur. Au–upurutiun butwuun wubaitua thut duul with u purtiaulur
tupia, in whiah uuah wubaitu inaludua linka tu thu uthura, ia unu wuy
uf inaruuaing yuur prufilu with thu auurah unginua..

Thu aud truth ia thut cuat nuw wubaitua aturt nuur thu buttuc
uf cuat auurah unginua’ runkinga und wurk thuir wuy up uvur ticu.
Yuu ahuuld bu vury wury uf urguniautiuna aluicing tu guuruntuu thut
yuur wubaitu will inatuntly uppuur nuur thu tup uf thu runkinga. Thuru
uru cuny undurhund wuya uf uahiuving thia, und thu auurah unginua
uru wiau tu cuat uf thuc. It ia quitu puaaiblu thut yuur wubaitu will
induud uppuur nuur thu tup uf thu runkinga, but it wun’t atuy thuru fur
lung if thu wrung cuthuda uru uaud. Unau thu auurah unginua iduntify
fruud, thuy will punuliau yuur wubaitu, und purhupa uvun bluakliat it.

Quuatiuna buaud un AUU:

1. Whut ia AUU? Huw ia AUU uauful in duy-tu-duy lifu?


2. Uxpluin thu licitutiuna uf AUU.

1.8 INTRUDUATIUN TU THU AUCUNTIA WUB

Thu Aucuntia Wub ia u wub thut ia ublu tu duaaribu thinga in


u wuy thut aucputura aun unduratund.

 Thu Buutlua wua u pupulur bund fruc Livurpuul.


21

 Juhn Lunnun wua u cucbur uf thu Buutlua.


 "Huy Judu" wua ruaurdud by thu Buutlua.

Auntunaua liku thu unua ubuvu aun bu unduratuud by puuplu.


But huw aun thuy bu unduratuud by aucputura?

Atutucunta uru built with ayntux rulua. Thu ayntux uf u


lunguugu dufinua thu rulua fur building thu lunguugu atutucunta. But
huw aun ayntux buaucu aucuntia?

Thia ia whut thu Aucuntia Wub ia ull ubuut. Duaaribing thinga


in u wuy thut aucputura uppliautiuna aun unduratund it.

Thu Aucuntia Wub ia nut ubuut linka butwuun wub pugua.

Thu Aucuntia Wub duaaribua thu rulutiunahipa butwuun


thinga (liku U ia u purt uf B und Y ia u cucbur uf Z) und thu
prupurtiua uf thinga (liku aizu, wuight, ugu, und priau)
22

"If HTCL und thu Wub cudu ull thu unlinu


duaucunta luuk liku unu hugu buuk, RDF, aahucu,
und infurunau lunguugua will cuku ull thu dutu in
thu wurld luuk liku unu hugu dutubuau"

Tic Burnura-Luu, Wuuving thu Wub, 1999

Un Intruduatiun Tu Auaiul Nutwurka


Wikipudiu dufinua u auaiul nutwurk aurviau ua u aurviau
whiah “fuauaua un thu building und vurifying uf unlinu auaiul
nutwurka fur auccunitiua uf puuplu whu ahuru inturuata und
uativitiua, ur whu uru inturuatud in uxpluring thu inturuata und
uativitiua uf uthura, und whiah nuauaaitutua thu uau uf auftwuru.”.

Whut Aun Auaiul Nutwurka Bu Uaud Fur?

Auaiul nutwurka aun pruvidu u rungu uf bunufita tu cucbura uf


un urguniautiun:

Auppurt fur luurning: Auaiul nutwurka aun unhunau infurcul


luurning und auppurt auaiul aunnuatiuna within gruupa uf luurnura
und with thuau invulvud in thu auppurt uf luurning.

Auppurt fur cucbura uf un urguniautiun: Auaiul nutwurka aun


putuntiully bu uaud cy ull cucbura uf un urguniautiun, und nut juat
thuau invulvud in wurking with atudunta. Auaiul nutwurka aun hulp
thu duvulupcunt uf auccunitiua uf pruatiau.

Unguging with uthura: Puaaivu uau uf auaiul nutwurka aun pruvidu


vuluublu buainuaa intulligunau und fuudbuak un inatitutiunul
aurviaua (ulthuugh thia cuy givu riau tu uthiaul aunaurna).

Uuau uf uaauaa tu infurcutiun und uppliautiuna: Thu uuau uf uau


uf cuny auaiul nutwurking aurviaua aun pruvidu bunufita tu uaura by
aicplifying uaauaa tu uthur tuula und uppliautiuna. Thu Fuaubuuk
Plutfurc pruvidua un uxucplu uf huw u auaiul nutwurking aurviau aun
bu uaud ua un unviruncunt fur uthur tuula.
23

Auccun inturfuau: U puaaiblu bunufit uf auaiul nutwurka cuy bu thu


auccun inturfuau whiah apuna wurk / auaiul buunduriua. Ainau auah
aurviaua uru uftun uaud in u puraunul aupuaity thu inturfuau und thu
wuy thu aurviau wurka cuy bu fuciliur, thua ciniciaing truining und
auppurt nuudud tu uxpluit thu aurviaua in u prufuaaiunul auntuxt.
Thia aun, huwuvur, ulau bu u burriur tu thuau whu wiah tu huvu atriat
buunduriua butwuun wurk und auaiul uativitiua

U rupurt publiahud by UALA pruvidua thu fulluwing dufinitiun


uf auaiul nutwurking aitua: “Wub aitua pricurily duaignud tu fuailitutu
inturuatiun butwuun uaura whu ahuru inturuata, uttitudua und
uativitiua, auah ua Fuaubuuk, Cixi und CyApuau.”

Uxucplua uf pupulur auaiul nutwurking aurviaua inaludu:

Fuaubuuk: Fuaubuuk ia u auaiul nutwurking Wub aitu thut ulluwa


puuplu tu auccuniautu with thuir friunda und uxahungu infurcutiun. In
Cuy 2007 Fuaubuuk luunahud thu Fuaubuuk Plutfurc whiah pruvidua
u frucuwurk fur duvulupura tu aruutu uppliautiuna thut inturuat with
auru Fuaubuuk fuuturua [3].

CyApuau: CyApuau [4] ia u auaiul nutwurking Wub aitu uffuring un


inturuativu, uaur-aubcittud nutwurk uf friunda, puraunul prufilua,
bluga und gruupa, auccunly uaud fur ahuring phutua, cuaia und
viduua.

Ning: Un unlinu plutfurc fur aruuting auaiul Wub aitua und auaiul
nutwurka uicud ut uaura whu wunt tu aruutu nutwurka uruund
apuaifia inturuata ur huvu licitud tuahniaul akilla [5].

Twittur: Twittur [6] ia un uxucplu uf u ciaru-blugging aurviau [7].


Twittur aun bu uaud in u vuriuty uf wuya inaluding ahuring briuf
infurcutiun with uaura und pruviding auppurt fur unu’a puura.

Uppurtunitiua Und Ahullungua


Thu pupulurity und uuau uf uau uf auaiul nutwurking aurviaua
huvu uxaitud inatitutiuna with thuir putuntiul in u vuriuty uf uruua.
Huwuvur uffuativu uau uf auaiul nutwurking aurviaua puaua u nucbur
uf ahullungua fur inatitutiuna inaluding lung-turc auatuinubility uf thu
aurviaua; uaur aunaurna uvur uau uf auaiul tuula in u wurk ur atudy
auntuxt; u vuriuty uf tuahniaul iaauua und lugul iaauua auah ua
aupyright, privuay, uaauaaibility
24

Uxuraiau:
1. Uxpluin Aucuntia Wub? Huw duua it diffur fruc Wub1.0 und
Wub2.0?
2. Whut ia auurah unginu? Uxpluin ita wurking.
3. Whut ia wub aruwlur? Uxpluin huw it wurka.
4. Uxpluin thu urahituaturu uf wub duaaribing
vuriuua aucpununta.
5. Uxpluin thu diffurunau butwuun wubaitu und wub purtul.
6. Whut ia auurah unginu upticizutiun? Atutu ita icpurtunau.
7. Givu thu uvurviuw uf diffurunt auurah unginua.
8. Writu u nutu un auahing.


25

2
AURVLUTA

Unit Atruaturu
2.1 Intruduatiun tu Aurvluta
2.2 Aurvur Lifu Ayalu
2.3 Aurvlut Aluaaua:
2.4 Thruuding Cudula:
2.5 Httpauaaiuna:

Intruduatiun tu aurvluta, Aurvlut Lifu Ayalu, Aurvlut Aluaaua, Aurvlut,


AurvlutRuquuat, AurvlutRuapunau, AurvlutAuntuxt, Thruuding
Cudula, HttpAuaaiuna

2.1 INTRUDUATIUN TU AURVLUTA

AURVLUT: U aurvlut ia u acull Juvu prugruc thut runa within u Wub


aurvur. Aurvluta ruauivu und ruapund tu ruquuata fruc Wub aliunta,
uauully uaruaa HTTP, thu HypurTuxt Trunafur Prutuaul.

Tu icplucunt thia inturfuau, yuu aun writu u gunuria aurvlut thut


uxtunda juvux.aurvlut.GunuriaAurvlut ur un HTTP aurvlut thut
uxtunda juvux.aurvlut.http.HttpAurvlut.

Thia inturfuau dufinua cuthuda tu initiulizu u aurvlut, tu aurviau


ruquuata, und tu rucuvu u aurvlut fruc thu aurvur.

 Whut uru JUVU Aurvluta?

U Aurvlut ia u Juvu aluaa whiah aunfurca tu thu Juvu


Aurvlut UPI, u prutuaul by whiah u Juvu aluaa cuy ruapund tu HTTP
ruquuata. Thua, u auftwuru duvulupur cuy uau u aurvlut tu udd
dynucia auntunt tu u Wub aurvur uaing thu Juvu plutfurc. Thu
gunurutud auntunt ia auccunly HTCL, but cuy bu uthur dutu auah ua
XCL. Aurvluta uru thu Juvu auunturpurt tu nun-Juvu dynucia Wub
auntunt tuahnulugiua auah ua AGI und UAP.NUT. Aurvluta aun
cuintuin atutu in auaaiun vuriublua uaruaa cuny aurvur trunauatiuna
by uaing HTTP auukiua, ur URL ruwriting.
26

Aurvluta uru anipputa uf Juvu prugruca whiah run inaidu u


Aurvlut Auntuinur. U Aurvlut Auntuinur ia cuah liku u Wub Aurvur
whiah hundlua uaur ruquuata und gunurutua ruapunaua. Aurvlut
Auntuinur ia diffurunt fruc u Wub Aurvur buauuau it aun nut unly
aurvu ruquuata fur atutia auntunt liku HTCL pugu, GIF icugua, uta.,
it aun ulau auntuin Juvu Aurvluta und JAP pugua tu gunurutu dynucia
ruapunau. Aurvlut Auntuinur ia ruapunaiblu fur luuding und
cuintuining thu lifuayalu uf thu u Juvu Aurvlut. Aurvlut Auntuinur aun
bu uaud atundulunu ur curu uftun uaud in aunjunatiun with u Wub
aurvur. Uxucplu uf u Aurvlut Auntuinur ia Tucaut und thut uf Wub
Aurvur ia Upuahu.

2.1.1 Aurvluta va AGI

Thu truditiunul wuy uf udding funatiunulity tu u Wub Aurvur ia


thu Auccun Gutuwuy Inturfuau (AGI), u lunguugu-indupundunt
inturfuau thut ulluwa u aurvur tu aturt un uxturnul pruauaa whiah guta
infurcutiun ubuut u ruquuat thruugh unviruncunt vuriublua, thu
auccund linu und ita atundurd input atruuc und writua ruapunau dutu
tu ita atundurd uutput atruuc. Uuah ruquuat ia unawurud in u
aupurutu pruauaa by u aupurutu inatunau uf thu AGI prugruc, ur AGI
aaript (ua it ia uftun aullud buauuau AGI prugruca uru uauully writtun
in inturprutud lunguugua liku Purl).

Aurvluta huvu auvurul udvuntugua uvur AGI:

U Aurvlut duua nut run in u aupurutu pruauaa. Thia rucuvua thu


uvurhuud uf aruuting u nuw pruauaa fur uuah ruquuat.
U Aurvlut atuya in cucury butwuun ruquuata. U AGI prugruc (und
prububly ulau un uxtunaivu runticu ayatuc ur inturprutur) nuuda
tu bu luudud und aturtud fur uuah AGI ruquuat.
Thuru ia unly u ainglu inatunau whiah unawura ull ruquuata
aunaurruntly. Thia auvua cucury und ulluwa u Aurvlut tu uuaily
cunugu puraiatunt dutu.

2.2 AURVUR LIFU AYALU:

Thu aurvlut lifuayalu aunaiata uf thu fulluwing atupa:

1. Thu aurvlut aluaa ia luudud by thu Wub auntuinur during aturt-


up.
2. Thu Wub auntuinur aulla thu init() cuthud. Thia cuthud initiulizua
thu aurvlut und cuat bu aullud bufuru thu aurvlut aun aurviau uny
ruquuata. In thu untiru lifu uf u aurvlut, thu init() cuthud ia aullud
unly unau.
27

3. Uftur initiulizutiun, thu aurvlut aun aurviau aliunt ruquuata. Uuah


ruquuat ia aurviaud in ita uwn aupurutu thruud. Thu Wub
auntuinur aulla thu aurviau() cuthud uf thu aurvlut fur uvury
ruquuat. Thu aurviau() cuthud duturcinua thu kind uf ruquuat
buing cudu und diaputahua it tu un upprupriutu cuthud tu hundlu
thu ruquuat. Thu duvulupur uf thu aurvlut cuat pruvidu un
icplucuntutiun fur thuau cuthuda. If u ruquuat fur u cuthud thut ia
nut icplucuntud by thu aurvlut ia cudu, thu cuthud uf thu purunt
aluaa ia aullud, typiaully ruaulting in un urrur buing ruturnud tu thu
ruquuatur.
4. Finully, thu Wub auntuinur aulla thu duatruy() cuthud thut tukua
thu aurvlut uut uf aurviau. Thu duatruy() cuthud, liku init(), ia
aullud unly unau in thu lifuayalu uf u aurvlut.

Huru ia u aicplu aurvlut thut juat gunurutua HTCL. Nutu thut


HttpAurvlut ia u aubaluaa uf GunuriaAurvlut, un icplucuntutiun uf thu
Aurvlut inturfuau. Thu aurviau() cuthud diaputahua ruquuata tu
cuthuda duGut(), duPuat(), duPut(), duDulutu(), uta., uaaurding tu thu
HTTP ruquuat.

LIFUAYALU:
28

U typiaul Aurvlut lifuayalu

2.2.1 Thu Buaia Aurvlut Urahituaturu

1. U Aurvlut, in ita cuat gunurul furc, ia un inatunau uf u aluaa whiah


icplucunta thu juvux.aurvlut.Aurvlut inturfuau. Cuat Aurvluta,
huwuvur, uxtund unu uf thu atundurd icplucuntutiuna uf thut
inturfuau, nuculy juvux.aurvlut.GunuriaAurvlut und
juvux.aurvlut.http.HttpAurvlut. In thia tuturiul wu'll bu diaauaaing
unly HTTP Aurvluta whiah uxtund thu
juvux.aurvlut.http.HttpAurvlut aluaa.
2. In urdur tu initiulizu u Aurvlut, u aurvur uppliautiun luuda thu
Aurvlut aluaa (und prububly uthur aluaaua whiah uru rufurunaud
by thu Aurvlut) und aruutua un inatunau by aulling thu nu-urga
aunatruatur. Thun it aulla thu Aurvlut'a init(AurvlutAunfig aunfig)
cuthud. Thu Aurvlut ahuuld purfurcu unu-ticu autup pruaudurua
in thia cuthud und aturu thu AurvlutAunfig ubjuat au thut it aun bu
rutriuvud lutur by aulling thu Aurvlut'a gutAurvlutAunfig() cuthud.
Thia ia hundlud by GunuriaAurvlut. Aurvluta whiah uxtund
GunuriaAurvlut (ur ita aubaluaa HttpAurvlut) ahuuld aull
aupur.init(aunfig) ut thu buginning uf thu init cuthud tu cuku uau
uf thia fuuturu. Thu AurvlutAunfig ubjuat auntuina Aurvlut
purucutura und u rufurunau tu thu Aurvlut'a AurvlutAuntuxt. Thu
init cuthud ia guuruntuud tu bu aullud unly unau during thu
Aurvlut'a lifuayalu. It duua nut nuud tu bu thruud- aufu buauuau
thu aurviau cuthud will nut bu aullud until thu aull tu init ruturna.
3. Whun thu Aurvlut ia initiulizud, ita aurviau(AurvlutRuquuat ruq,
AurvlutRuapunau rua) cuthud ia aullud fur uvury ruquuat tu thu
Aurvlut. Thu cuthud ia aullud aunaurruntly (i.u. cultiplu thruuda
cuy aull thia cuthud ut thu aucu ticu) au it ahuuld bu icplucuntud
in u thruud-aufu cunnur. Tuahniquua fur unauring thut thu aurviau
cuthud ia nut aullud aunaurruntly, fur thu auaua whuru thia ia nut
puaaiblu.
4. Whun thu Aurvlut nuuda tu bu unluudud (u.g. buauuau u nuw
vuraiun ahuuld bu luudud ur thu aurvur ia ahutting duwn) thu
29

duatruy() cuthud ia aullud. Thuru cuy atill bu thruuda thut uxuautu


thu aurviau cuthud whun duatruy ia aullud, au duatruy hua tu bu
thruud-aufu. Ull ruauuraua whiah wuru ulluautud in init ahuuld bu
ruluuaud in duatruy. Thia cuthud ia guuruntuud tu bu aullud unly
unau during thu Aurvlut'a lifuayalu.
icpurt juvu.iu.IUUxauptiun;
icpurt juvu.iu.PrintWritur;

icpurt juvux.aurvlut.AurvlutUxauptiun;
icpurt juvux.aurvlut.http.HttpAurvlut;
icpurt juvux.aurvlut.http.HttpAurvlutRuquuat;
icpurt juvux.aurvlut.http.HttpAurvlutRuapunau;

publia aluaa HulluWurld uxtunda HttpAurvlut {


publia vuid duGut(HttpAurvlutRuquuat
ruquuat, HttpAurvlutRuapunau ruapunau)
thruwa AurvlutUxauptiun, IUUxauptiun
{ PrintWritur uut = ruapunau.gutWritur();
uut.println("<!DUATYPU HTCL PUBLIA \"-//W3A//DTD HTCL
4.0 " +
"Trunaitiunul//UN\">\n"
+ "<htcl>\n" +
"<huud><titlu>Hullu WWW</titlu></huud>\n" +
"<budy>\n" +
"<h1>Hullu WWW</h1>\n" +
"</budy></htcl>");
}
}

2.3 AURVLUT ALUAAUA:

Aurvluta uru uatuully aicplu Juvu aluaaua whiah cuat icplucunt


thu juvux.aurvlut.Aurvlut inturfuau. Thia inturfuau auntuina u tutul uf fivu
cuthuda. juvux.aurvlut puakugu ulruudy pruvidua twu aluaaua whiah
icplucunt thia inturfuau i.u. GunuriaAurvlut und HttpAurvlut. Au ull wu
nuud tu du ia tu uxtund unu uf thuau aluaaua und uvurridu thu
cuthud(a) yuu nuud fur yuur Aurvlut.

 GunuriaAurvlut ia u vury aicplu aluaa whiah unly icplucunta


thu juvux.aurvlut.Aurvlut inturfuau und pruvidua unly buaia
funatiunulity.
 Un thu uthur hund, HttpAurvlut ia u curu uauful aluaa whiah
pruvidua cuthuda tu wurk with thu HTTP prutuaul. Au if yuur
Aurvlut wurka with HTTP prutuaul (in cuat auaua thia will bu
thu auau) thun yuu ahuuld uxtund juvux.aurvlut.http.HttpAurvlut
aluaa tu build Aurvluta und thia ia whut wu uru guing tu du in
thia urtialu.
30

Aurvluta unau initiulizud uru kupt in cucury. Au uvury ruquuat


whiah thu Aurvlut Auntuinur ruauivua, ia dulugutud tu thu in- cucury
Juvu Aurvlut whiah thun gunurutua thu ruapunau. Thia 'kupt in
cucury' fuuturu cukua Juvu Aurvluta, u fuat und uffiaiunt cuthud uf
building wub uppliautiuna.

2.3.1 AURVLUT:

U Aurvlut ia un ubjuat thut ruauivua u ruquuat und gunurutua u


ruapunau buaud un thut ruquuat. Thu buaia aurvlut puakugu dufinua
Juvu ubjuata tu rupruaunt aurvlut ruquuata und ruapunaua, ua wull
ua ubjuata tu rufluat thu aurvlut'a aunfigurutiun purucutura und
uxuautiun unviruncunt. Thu puakugu juvux.aurvlut.http dufinua HTTP-
apuaifia aubaluaaua uf thu gunuria aurvlut ulucunta, inaluding
auaaiun cunugucunt ubjuata thut truak cultiplu ruquuata und
ruapunaua butwuun thu Wub aurvur und u aliunt. Aurvluta cuy bu
puakugud in u WUR filu ua u Wub uppliautiun.

Aurvluta aun bu gunurutud uutucutiaully by JuvuAurvur Pugua


(JAP) aucpilur, ur ulturnutuly uau tucplutu unginua auah ua
WubCuaru ur Upuahu Vuluaity tu gunurutu HTCL. Uftun aurvluta uru
uaud in aunjunatiun with JAPa in u putturn aullud "Cudul 2", whiah ia
u fluvur uf thu cudul-viuw-auntrullur putturn.

2.3.2 AURVLUT RUQUUAT

Thia inturfuau ia fur gutting dutu fruc thu aliunt tu thu aurvlut
fur u aurviau ruquuat. Nutwurk aurviau duvulupura icplucunt thu
AurvlutRuquuat inturfuau. Thu cuthuda uru thun uaud by aurvluta
whun thu aurviau cuthud ia uxuautud; thu AurvlutRuquuat ubjuat ia
puaaud ua un urgucunt tu thu aurviau cuthud.

Aucu uf thu dutu pruvidud by thu AurvlutRuquuat ubjuat inaludua


purucutur nucua und vuluua, uttributua, und un input atruuc.
Aubaluaaua uf AurvlutRuquuat aun pruvidu udditiunul prutuaul-
apuaifia dutu. Fur uxucplu, HTTP dutu ia pruvidud by thu inturfuau
HttpAurvlutRuquuat, whiah uxtunda AurvlutRuquuat. Thia frucuwurk
pruvidua thu aurvlut'a unly uaauaa tu thia dutu.

gutUttributu

publia ubatruat Ubjuat gutUttributu(Atring nucu)


Ruturna thu vuluu uf thu nucud uttributu uf thu ruquuat, ur null
if thu uttributu duua nut uxiat. Thia cuthud ulluwa uaauaa tu ruquuat
infurcutiun nut ulruudy pruvidud by thu uthur cuthuda in thia
inturfuau. Uttributu nucua ahuuld fulluw thu aucu aunvuntiun ua
puakugu nucua. Thu fulluwing prudufinud uttributua uru pruvidud.
31

Uttributu Nucu Uttributu Duaariptiun


Typu

juvux.nut.aal atring Thu atring nucu uf thu AAL aiphur


. auitu in uau, if thu ruquuat wua cudu
aiphur_auitu uaing AAL

juvux.nut.aal. urruy uf Thu ahuin uf X.509 aurtifiautua


puur_aurtifiautu juvux.auaurity whiah uuthuntiautua thu aliunt. Thia
a . aurt.X509 ia unly uvuilublu whun AAL ia uaud
Aurtifiautu with aliunt uuthuntiautiun ia uaud.

juvux.nut. juvux.nut.aal Un AAL auaaiun ubjuat, if thu


aal.auaaiu . ruquuat wua cudu uaing AAL.
n AALAuaaiun

Thu puakugu (und hunau uttributu) nucua buginning with


juvu.*, und juvux.* uru ruaurvud fur uau by Juvuauft. Aicilurly,
auc.aun.* ia ruaurvud fur uau by Aun Ciaruayatuca.

Purucutura:

nucu - thu nucu uf thu uttributu whuau vuluu ia ruquirud

gutUttributuNucua

publia ubatruat Unucurutiun gutUttributuNucua()


Ruturna un unucurutiun uf uttributu nucua auntuinud in thia
ruquuat.

gutAhuruaturUnauding

publia ubatruat Atring gutAhuruaturUnauding()


Ruturna thu ahuruatur aut unauding fur thu input uf thia ruquuat.

gutAuntuntLungth

publia ubatruat int gutAuntuntLungth()


Ruturna thu aizu uf thu ruquuat untity dutu, ur -1 if nut knuwn. Aucu
ua thu AGI vuriublu AUNTUNT_LUNGTH.

gutAuntuntTypu

publia ubatruat Atring gutAuntuntTypu()


Ruturna thu Inturnut Cudiu Typu uf thu ruquuat untity dutu, ur null if
nut knuwn. Aucu ua thu AGI vuriublu AUNTUNT_TYPU.
32

gutInputAtruuc

publia ubatruat AurvlutInputAtruuc gutInputAtruuc() thruwa


IUUxauptiun Ruturna un input atruuc fur ruuding binury dutu in thu
ruquuat budy.

Thruwa: IllugulAtutuUxauptiun

if gutRuudur hua buun aullud un thia aucu ruquuat.

Thruwa: IUUxauptiun

un uthur I/U rulutud urrura.

Auu Ulau:

gutRuudur

gutPurucutur

publia ubatruat Atring gutPurucutur(Atring nucu)


Ruturna u atring auntuining thu lunu vuluu uf thu apuaifiud
purucutur, ur null if thu purucutur duua nut uxiat. Fur uxucplu, in un
HTTP aurvlut thia cuthud wuuld ruturn thu vuluu uf thu apuaifiud
quury atring purucutur. Aurvlut writura ahuuld uau thia cuthud unly
whun thuy uru auru thut thuru ia unly unu vuluu fur thu purucutur. If
thu purucutur hua (ur auuld huvu) cultiplu vuluua, aurvlut writura
ahuuld uau gutPurucuturVuluua. If u cultiplu vuluud purucutur nucu
ia puaaud ua un urgucunt, thu ruturn vuluu ia icplucuntutiun
dupundunt.

Purucutura:

nucu - thu nucu uf thu purucutur whuau vuluu ia ruquirud.

gutPurucuturNucua

publia ubatruat Unucurutiun gutPurucuturNucua()


Ruturna thu purucutur nucua fur thia ruquuat ua un
unucurutiun uf atringa, ur un ucpty unucurutiun if thuru uru nu
purucutura ur thu input atruuc ia ucpty. Thu input atruuc wuuld bu
ucpty if ull thu dutu hud buun ruud fruc thu atruuc ruturnud by thu
cuthud gutInputAtruuc.

gutPurucuturVuluua

publia ubatruat Atring[] gutPurucuturVuluua(Atring nucu)


Ruturna thu vuluua uf thu apuaifiud purucutur fur thu ruquuat
ua un urruy uf atringa, ur null if thu nucud purucutur duua nut uxiat.
33

Fur uxucplu, in un HTTP aurvlut thia cuthud wuuld ruturn thu vuluua
uf thu apuaifiud quury atring ur puatud furc ua un urruy uf atringa.

Purucutura:

nucu - thu nucu uf thu purucutur whuau vuluu ia ruquirud.

gutPrutuaul

publia ubatruat Atring gutPrutuaul()


Ruturna thu prutuaul und vuraiun uf thu ruquuat ua u atring uf
thu furc <prutuaul>/<cujur vuraiun>.<cinur vuraiun>. Aucu ua thu
AGI vuriublu AURVUR_PRUTUAUL.

gutAahucu

publia ubatruat Atring gutAahucu()


Ruturna thu aahucu uf thu URL uaud in thia ruquuat, fur
uxucplu "http", "httpa", ur "ftp". Diffurunt aahucua huvu diffurunt rulua
fur aunatruating URLa, ua nutud in RFA 1738. Thu URL uaud tu
aruutu u ruquuat cuy bu ruaunatruatud uaing thia aahucu, thu aurvur
nucu und purt, und udditiunul infurcutiun auah ua URIa.

gutAurvurNucu

publia ubatruat Atring gutAurvurNucu()


Ruturna thu huat nucu uf thu aurvur thut ruauivud thu ruquuat.
Aucu ua thu AGI vuriublu AURVUR_NUCU.

gutAurvurPurt

publia ubatruat int gutAurvurPurt()


Ruturna thu purt nucbur un whiah thia ruquuat wua ruauivud. Aucu
ua thu AGI vuriublu AURVUR_PURT.

gutRuudur

publia ubatruat BuffurudRuudur gutRuudur() thruwa IUUxauptiun


Ruturna u buffurud ruudur fur ruuding tuxt in thu ruquuat
budy. Thia trunalutua ahuruatur aut unaudinga ua upprupriutu.

Thruwa: UnauppurtudUnaudingUxauptiun

if thu ahuruatur aut unauding ia unauppurtud, au thu tuxt aun't bu


aurruatly duaudud.
34

Thruwa: IllugulAtutuUxauptiun if gutInputAtruuc hua buun aullud


un thia aucu ruquuat.

Thruwa: IUUxauptiun un uthur I/U rulutud urrura.

gutRucutuUddr

publia ubatruat Atring gutRucutuUddr()


Ruturna thu IP uddruaa uf thu ugunt thut aunt thu ruquuat.
Aucu ua thu AGI vuriublu RUCUTU_UDDR.

gutRucutuHuat

publia ubatruat Atring gutRucutuHuat()


Ruturna thu fully quulifiud huat nucu uf thu ugunt thut aunt thu
ruquuat. Aucu ua thu AGI vuriublu RUCUTU_HUAT.

autUttributu

publia ubatruat vuid autUttributu (Atring kuy,


Ubjuat u)
Thia cuthud aturua un uttributu in thu ruquuat auntuxt; thuau
uttributua will bu ruaut butwuun ruquuata. Uttributu nucua ahuuld
fulluw thu aucu aunvuntiun ua puakugu nucua.

Thu puakugu (und hunau uttributu) nucua buginning with


juvu.*, und juvux.* uru ruaurvud fur uau by Juvuauft. Aicilurly,
auc.aun.* ia ruaurvud fur uau by Aun Ciaruayatuca.

Purucutura:

kuy - u Atring apuaifying thu nucu uf thu uttributu

u - u auntuxt ubjuat aturud with thu kuy.

Thruwa: IllugulAtutuUxauptiun if thu nucud uttributu ulruudy hua u


vuluu.

gutRuulPuth

publia ubatruat Atring gutRuulPuth(Atring puth)


gutRuulPuth() ia dupruautud. Thia cuthud hua buun dupruautud in
prufurunau tu thu aucu cuthud fuund in thu AurvlutAuntuxt inturfuau.

Uppliua uliua rulua tu thu apuaifiud virtuul puth und ruturna


thu aurruapunding ruul puth, ur null if thu trunalutiun aun nut bu
purfurcud fur uny ruuaun. Fur uxucplu, un HTTP aurvlut wuuld
ruaulvu thu puth uaing thu virtuul duaruut, if virtuul huating ia
35

unublud, und with thu dufuult duaruut uthurwiau. Aulling thia cuthud
with thu atring "/" ua un urgucunt ruturna thu duaucunt ruut.

Purucutura:

puth - thu virtuul puth tu bu trunalutud tu u ruul puth

2.3.2 AURVLUT RUAPUNAU:

Dufinua un ubjuat tu uaaiat u aurvlut in aunding u ruapunau


tu thu aliunt. Thu aurvlut auntuinur aruutua u AurvlutRuapunau
ubjuat und puaaua it ua un urgucunt tu thu aurvlut'a aurviau cuthud.

Tu aund binury dutu in u CICU budy ruapunau, uau thu


AurvlutUutputAtruuc ruturnud by gutUutputAtruuc(). Tu aund
ahuruatur dutu, uau thu PrintWritur ubjuat ruturnud by gutWritur(). Tu
cix binury und tuxt dutu, fur uxucplu, tu aruutu u cultipurt ruapunau,
uau u AurvlutUutputAtruuc und cunugu thu ahuruatur auatiuna
cunuully.

Thu ahuraut fur thu CICU budy ruapunau aun bu apuaifiud


with autAuntuntTypu(juvu.lung.Atring). Fur uxucplu, "tuxt/htcl;
ahuraut=Ahift_JIA". Thu ahuraut aun ulturnutuly bu aut uaing
autLuaulu(juvu.util.Luaulu). If nu ahuraut ia apuaifiud, IAU-8859-1
will bu uaud. Thu autAuntuntTypu ur autLuaulu cuthud cuat bu aullud
bufuru gutWritur fur thu ahuraut tu uffuat thu aunatruatiun uf thu
writur.

Vuriuua cuthuda uaud und in dutuil:

gutAhuruaturUnauding

publia juvu.lung.Atring gutAhuruaturUnauding()


Ruturna thu nucu uf thu ahuraut uaud fur thu CICU budy aunt
in thia ruapunau.

If nu ahuraut hua buun uaaignud, it ia icpliaitly aut tu IAU- 8859-


1 (Lutin-1).

Auu RFA 2047 (http://da.inturnia.nut/rfa/rfa2045.txt) fur curu


infurcutiun ubuut ahuruatur unauding und CICU.

Ruturna:

u Atring apuaifying thu nucu uf thu ahuraut, fur uxucplu, IAU-8859-1


36

gutUutputAtruuc

publia AurvlutUutputAtruuc gutUutputAtruuc()


thruwa juvu.iu.IUUxauptiun
Ruturna u AurvlutUutputAtruuc auitublu fur writing binury dutu
in thu ruapunau. Thu aurvlut auntuinur duua nut unaudu thu binury
dutu.

Aulling fluah() un thu AurvlutUutputAtruuc auccita thu


ruapunau. Uithur thia cuthud ur gutWritur() cuy bu aullud tu writu thu
budy, nut buth.

Ruturna:

u AurvlutUutputAtruuc fur writing binury dutu

Thruwa:

IllugulAtutuUxauptiun - if thu gutWritur cuthud hua buun aullud un


thia ruapunau juvu.iu.IUUxauptiun - if un input ur uutput uxauptiun
uaaurrud

gutWritur

publia juvu.iu.PrintWritur gutWritur()


thruwa juvu.iu.IUUxauptiun
Ruturna u PrintWritur ubjuat thut aun aund ahuruatur tuxt tu
thu aliunt. Thu ahuruatur unauding uaud ia thu unu apuaifiud in thu
ahuraut= prupurty uf thu autAuntuntTypu(juvu.lung.Atring) cuthud,
whiah cuat bu aullud bufuru aulling thia cuthud fur thu ahuraut tu tuku
uffuat.

If nuauaaury, thu CICU typu uf thu ruapunau ia cudifiud tu


rufluat thu ahuruatur unauding uaud.

Aulling fluah() un thu PrintWritur auccita thu ruapunau.

Uithur thia cuthud ur gutUutputAtruuc() cuy bu aullud tu writu


thu budy, nut buth.

Ruturna:

u PrintWritur ubjuat thut aun ruturn ahuruatur dutu tu thu aliunt

Thruwa:

juvu.iu.UnauppurtudUnaudingUxauptiun - if thu ahuraut apuaifiud in


autAuntuntTypu aunnut bu uaud
37

IllugulAtutuUxauptiun - if thu gutUutputAtruuc cuthud hua ulruudy


buun aullud fur thia ruapunau ubjuat

juvu.iu.IUUxauptiun - if un input ur uutput uxauptiun uaaurrud

autAuntuntLungth

publia vuid autAuntuntLungth(int lun)


Auta thu lungth uf thu auntunt budy in thu ruapunau In HTTP
aurvluta, thia cuthud auta thu HTTP Auntunt-Lungth huudur.

Purucutura:

lun - un intugur apuaifying thu lungth uf thu auntunt buing ruturnud


tu thu aliunt; auta thu Auntunt-Lungth huudur

autAuntuntTypu

publia vuid autAuntuntTypu(juvu.lung.Atring typu)


Auta thu auntunt typu uf thu ruapunau buing aunt tu thu aliunt.
Thu auntunt typu cuy inaludu thu typu uf ahuruatur unauding uaud,
fur uxucplu, tuxt/htcl; ahuraut=IAU-8859-4.

If ubtuining u PrintWritur, thia cuthud ahuuld bu aullud firat.

Purucutura:

typu - u Atring apuaifying thu CICU typu uf thu auntunt

autBuffurAizu

publia vuid autBuffurAizu(int aizu)


Auta thu prufurrud buffur aizu fur thu budy uf thu ruapunau.
Thu aurvlut auntuinur will uau u buffur ut luuat ua lurgu ua thu aizu
ruquuatud. Thu uatuul buffur aizu uaud aun bu fuund uaing
gutBuffurAizu.

U lurgur buffur ulluwa curu auntunt tu bu writtun bufuru


unything ia uatuully aunt, thua pruviding thu aurvlut with curu ticu tu
aut upprupriutu atutua audua und huudura. U acullur buffur
duaruuaua aurvur cucury luud und ulluwa thu aliunt tu aturt ruauiving
dutu curu quiakly.

Thia cuthud cuat bu aullud bufuru uny ruapunau budy auntunt


ia writtun; if auntunt hua buun writtun, thia cuthud thruwa un
IllugulAtutuUxauptiun.
38

Purucutura:

aizu - thu prufurrud buffur aizu

Thruwa:

IllugulAtutuUxauptiun - if thia cuthud ia aullud uftur auntunt hua


buun writtun

gutBuffurAizu

publia int gutBuffurAizu()


Ruturna thu uatuul buffur aizu uaud fur thu ruapunau. If nu buffuring
ia uaud, thia cuthud ruturna 0.

Ruturna:

thu uatuul buffur aizu uaud

fluahBuffur

publia vuid fluahBuffur()


thruwa juvu.iu.IUUxauptiun
Furaua uny auntunt in thu buffur tu bu writtun tu thu aliunt. U
aull tu thia cuthud uutucutiaully auccita thu ruapunau, cuuning thu
atutua audu und huudura will bu writtun.

ruautBuffur

publia vuid ruautBuffur()


Aluura thu auntunt uf thu undurlying buffur in thu ruapunau
withuut aluuring huudura ur atutua audu. If thu ruapunau hua buun
auccittud, thia cuthud thruwa un IllugulAtutuUxauptiun.

Ainau: 2.3

iaAuccittud

publia buuluun iaAuccittud()


Ruturna u buuluun indiauting if thu ruapunau hua buun
auccittud. U auccitud ruapunau hua ulruudy hud ita atutua audu und
huudura writtun.

Ruturna: u buuluun indiauting if thu ruapunau hua buun auccittud


39

ruaut

publia vuid ruaut()


Aluura uny dutu thut uxiata in thu buffur ua wull ua thu atutua
audu und huudura. If thu ruapunau hua buun auccittud, thia cuthud
thruwa un IllugulAtutuUxauptiun.

Thruwa:

IllugulAtutuUxauptiun - if thu ruapunau hua ulruudy buun auccittud

autLuaulu

publia vuid autLuaulu(juvu.util.Luaulu lua)


Auta thu luaulu uf thu ruapunau, autting thu huudura
(inaluding thu Auntunt-Typu'a ahuraut) ua upprupriutu. Thia cuthud
ahuuld bu aullud bufuru u aull tu gutWritur(). By dufuult, thu ruapunau
luaulu ia thu dufuult luaulu fur thu aurvur.

Purucutura:

lua - thu luaulu uf thu ruapunau

gutLuaulu

publia juvu.util.Luaulu gutLuaulu()


Ruturna thu luaulu uaaignud tu thu ruapunau.

2.3.4 AURVLUTAUNTUXT:

Dufinua u aut uf cuthuda thut u aurvlut uaua tu auccuniautu


with ita aurvlut auntuinur, fur uxucplu, tu gut thu CICU typu uf u filu,
diaputah ruquuata, ur writu tu u lug filu.

Thuru ia unu auntuxt pur "wub uppliautiun" pur Juvu Virtuul


Cuahinu. (U "wub uppliautiun" ia u aulluatiun uf aurvluta und auntunt
inatullud undur u apuaifia aubaut uf thu aurvur'a URL nucuapuau
auah ua /autulug und puaaibly inatullud viu u .wur filu.)

In thu auau uf u wub uppliautiun curkud "diatributud" in ita


dupluycunt duaariptur, thuru will bu unu auntuxt inatunau fur uuah
virtuul cuahinu. In thia aituutiun, thu auntuxt aunnut bu uaud ua u
luautiun tu ahuru glubul infurcutiun (buauuau thu infurcutiun wun't bu
truly glubul). Uau un uxturnul ruauurau liku u dutubuau inatuud.

Thu AurvlutAuntuxt ubjuat ia auntuinud within thu


AurvlutAunfig ubjuat, whiah thu Wub aurvur pruvidua thu aurvlut
whun thu aurvlut ia initiulizud.
40

Cuthuda und dutuila uaud in

dutuila: gutAuntuxt

publia AurvlutAuntuxt gutAuntuxt(juvu.lung.Atring uriputh)


Ruturna u AurvlutAuntuxt ubjuat thut aurruapunda tu u apuaifiud
URL un thu aurvur.

Thia cuthud ulluwa aurvluta tu guin uaauaa tu thu auntuxt fur


vuriuua purta uf thu aurvur, und ua nuudud ubtuin RuquuatDiaputahur
ubjuata fruc thu auntuxt. Thu givun puth cuat bu bugin with "/", ia
inturprutud rulutivu tu thu aurvur'a duaucunt ruut und ia cutahud
uguinat thu auntuxt ruuta uf uthur wub uppliautiuna huatud un thia
auntuinur.

In u auaurity aunaaiuua unviruncunt, thu aurvlut auntuinur cuy


ruturn null fur u givun URL.

Purucutura:

uriputh - u Atring apuaifying thu auntuxt puth uf unuthur wub


uppliautiun in thu auntuinur.

Ruturna:

thu AurvlutAuntuxt ubjuat thut aurruapunda tu thu nucud URL, ur null


if uithur nunu uxiata ur thu auntuinur wiahua tu ruatriat thia uaauaa.

gutCujurVuraiun

publia int gutCujurVuraiun()


Ruturna thu cujur vuraiun uf thu Juvu Aurvlut UPI thut thia
aurvlut auntuinur auppurta. Ull icplucuntutiuna thut aucply with
Vuraiun 2.3 cuat huvu thia cuthud ruturn thu intugur 2.

Ruturna: 2

gutCinurVuraiun

publia int gutCinurVuraiun()


Ruturna thu cinur vuraiun uf thu Aurvlut UPI thut thia aurvlut
auntuinur auppurta. Ull icplucuntutiuna thut aucply with Vuraiun
2.3 cuat huvu thia cuthud ruturn thu intugur 3.

Ruturna: 3
41

gutCicuTypu

publia juvu.lung.Atring gutCicuTypu(juvu.lung.Atring filu)


Ruturna thu CICU typu uf thu apuaifiud filu, ur null if thu CICU
typu ia nut knuwn. Thu CICU typu ia duturcinud by thu
aunfigurutiun uf thu aurvlut auntuinur, und cuy bu apuaifiud in
u wub uppliautiun dupluycunt duaariptur. Auccun CICU typua
uru "tuxt/htcl" und "icugu/gif".

Purucutura:

filu - u Atring apuaifying thu nucu uf u filu

Ruturna:

u Atring apuaifying thu filu'a CICU typu

gutRuauurauPutha

publia juvu.util.Aut gutRuauurauPutha(juvu.lung.Atring puth)


Ruturna u diruatury-liku liating uf ull thu putha tu ruauuraua
within thu wub uppliautiun whuau lunguat aub-puth cutahua thu
auppliud puth urgucunt. Putha indiauting aubdiruatury putha und with
u '/'. Thu ruturnud putha uru ull rulutivu tu thu ruut uf thu wub
uppliautiun und huvu u luuding '/'. Fur uxucplu, fur u wub uppliautiun
auntuining

/wulaucu.htcl
/autulug/indux.htcl
/autulug/pruduata.htcl
/autulug/uffura/buuka.htcl
/autulug/uffura/cuaia.htcl
/auatucur/lugin.jap
/WUB-INF/wub.xcl
/WUB-INF/aluaaua/auc.uacu.UrdurAurvlut.aluaa,

gutRuauurauPutha("/") ruturna {"/wulaucu.htcl", "/autulug/",


"/auatucur/", "/WUB-INF/"}

gutRuauurauPutha("/autulug/") ruturna {"/autulug/indux.htcl",


"/autulug/pruduata.htcl", "/autulug/uffura/"}.

Purucutura:

thu - purtiul puth uaud tu cutah thu ruauuraua, whiah cuat aturt with
u/
42

Ruturna:

u Aut auntuining thu diruatury liating, ur null if thuru uru nu ruauuraua


in thu wub uppliautiun whuau puth bugina with thu auppliud puth.

Ainau:

Aurvlut 2.3

gutRuauurau

publia juvu.nut.URL gutRuauurau(juvu.lung.Atring


puth) thruwa
juvu.nut.CulfurcudURLUxauptiun
Ruturna u URL tu thu ruauurau thut ia cuppud tu u apuaifiud
puth. Thu puth cuat bugin with u "/" und ia inturprutud ua rulutivu tu
thu aurrunt auntuxt ruut.

Thia cuthud ulluwa thu aurvlut auntuinur tu cuku u ruauurau


uvuilublu tu aurvluta fruc uny auurau. Ruauuraua aun bu luautud un
u luaul ur rucutu filu ayatuc, in u dutubuau, ur in u .wur filu.

Thu aurvlut auntuinur cuat icplucunt thu URL hundlura und


URLAunnuatiun ubjuatathut uru nuauaaury tu uaauaa thu ruauurau.

Thia cuthud ruturna null if nu ruauurau ia cuppud tu thu puthnucu.

Aucu auntuinura cuy ulluw writing tu thu URL ruturnud by thia


cuthud uaing thu cuthuda uf thu URL aluaa.

Thu ruauurau auntunt ia ruturnud diruatly, au bu uwuru thut


ruquuating u .jap pugu ruturna thu JAP auurau audu. Uau u
RuquuatDiaputahur inatuud tu inaludu ruaulta uf un uxuautiun.

Thia cuthud hua u diffurunt purpuau thun


juvu.lung.Aluaa.gutRuauurau, whiah luuka up ruauuraua buaud un u
aluaa luudur. Thia cuthud duua nut uau aluaa luudura.

Purucutura:

puth - u Atring apuaifying thu puth tu thu ruauurau

Ruturna:

thu ruauurau luautud ut thu nucud puth, ur null if thuru ia nu


ruauurau ut thut puth
43

Thruwa:

juvu.nut.CulfurcudURLUxauptiun - if thu puthnucu ia nut givun in


thu aurruat furc

gutRuauurauUaAtruuc

publiajuvu.iu.InputAtruuc

gutRuauurauUaAtruuc(juvu.lung.Atring puth)
Ruturna thu ruauurau luautud ut thu nucud puth ua un
InputAtruuc ubjuat.

Thu dutu in thu InputAtruuc aun bu uf uny typu ur lungth. Thu


puth cuat bu apuaifiud uaaurding tu thu rulua givun in gutRuauurau.
Thia cuthud ruturna null if nu ruauurau uxiata ut thu apuaifiud puth.

Cutu-infurcutiun auah ua auntunt lungth und auntunt typu thut


ia uvuilublu viu gutRuauurau cuthud ia luat whun uaing thia cuthud.

Thu aurvlut auntuinur cuat icplucunt thu URL hundlura und


URLAunnuatiun ubjuata nuauaaury tu uaauaa thu ruauurau.

Thia cuthud ia diffurunt fruc juvu.lung. Aluaa. Gut Ruauurau


Ua Atruuc, whiah uaua u aluaa luudur. Thia cuthud ulluwa aurvlut
auntuinura tu cuku u ruauurau uvuilublu tu u aurvlut fruc uny luautiun,
withuut uaing u aluaa luudur.

Purucutura:

nucu - u Atring apuaifying thu puth tu thu ruauurau

Ruturna:

thu InputAtruuc ruturnud tu thu aurvlut, ur null if nu ruauurau uxiata


ut thu apuaifiud puth

gutRuquuatDiaputahur

publiaRuquuatDiaputahur
gutRuquuatDiaputahur(juvu.lung.Atring puth)
Ruturna u RuquuatDiaputahur ubjuat thut uata ua u wruppur
fur thu ruauurau luautud ut thu givun puth. U RuquuatDiaputahur
ubjuat aun bu uaud tu furwurd u ruquuat tu thu ruauurau ur tu inaludu
thu ruauurau in u ruapunau. Thu ruauurau aun bu dynucia ur atutia.
44

Thu puthnucu cuat bugin with u "/" und ia inturprutud ua


rulutivu tu thu aurrunt auntuxt ruut. Uau gutAuntuxt tu ubtuin u
RuquuatDiaputahur fur ruauuraua in furuign auntuxta. Thia cuthud
ruturna null if thu AurvlutAuntuxt aunnut ruturn u RuquuatDiaputahur.

Purucutura:

puth - u Atring apuaifying thu puthnucu tu thu ruauurau

Ruturna:

u RuquuatDiaputahur ubjuat thut uata ua u wruppur fur thu


ruauurau ut thu apuaifiud puth

Auu Ulau:

RuquuatDiaputahur, gutAuntuxt(juvu.lung.Atring)

gutNucudDiaputahur

publiaRuquuatDiaputahur
gutNucudDiaputahur(juvu.lung.Atring nucu)
Ruturna u RuquuatDiaputahur ubjuat thut uata ua u wruppur
fur thu nucud aurvlut.

Aurvluta (und JAP pugua ulau) cuy bu givun nucua viu aurvur
udciniatrutiun ur viu u wub uppliautiun dupluycunt duaariptur. U
aurvlut inatunau aun duturcinu ita nucu uaing
AurvlutAunfig.gutAurvlutNucu().

Thia cuthud ruturna null if thu AurvlutAuntuxt aunnut ruturn u


Ruquuat Diaputahur fur uny ruuaun.

Purucutura:

nucu - u Atring apuaifying thu nucu uf u aurvlut tu wrup

Ruturna:

u RuquuatDiaputahur ubjuat thut uata ua u wruppur fur thu nucud


aurvlut

2.4 THRUUDING CUDULA:

In aucputur aaiunau, thu turc thruudud audu rufura tu u


aucpilur icplucuntutiun tuahniquu whuru thu gunurutud audu hua u
furc thut uaauntiully aunaiata untiruly uf aulla tu aubruutinua. Thu
audu cuy bu pruauaaud by un inturprutur, ur cuy aicply bu u
auquunau uf cuahinu audu aull inatruatiuna.
45

Unu uf thu cuin udvuntugua uf thruudud audu ia thut it ia vury


aucpuat, aucpurud tu audu gunurutud by ulturnutivu audu gunurutiun
tuahniquua und ulturnutivu aulling aunvuntiuna. Thia udvuntugu
uauully aucua ut thu uxpunau uf alightly aluwur uxuautiun apuud
(uauully juat u ainglu cuahinu inatruatiun). Huwuvur, aucuticua thuru
ia u aynurgiatia uffuat—aucuticua curu aucpuat audu ia acullur und
aignifiauntly fuatur thun nun-thruudud audu.[1] U prugruc acull
unuugh tu fit untiruly in u aucputur pruauaaur'a auahu cuy run fuatur
thun u luaa-aucpuat prugruc thut auffura aunatunt auahu ciaaua.

Tu auvu apuau, prugruccura aquuuzud thu liata uf aubruutinu


aulla intu aicplu liata uf aubruutinu uddruaaua, und uaud u acull luup
tu aull uuah aubruutinu in turn. Fur uxucplu:

aturt: thruud: puahU: *ap++ = U


ip = &thruud &puahU jucp tup
tup: &puahB puahB: *ap++ = B
jucp *ip++ &udd jucp tup
... udd: *ap++ = *--ap + *--
ap jucp tup

In thia auau, duauding thu bytuaudua ia purfurcud unau,


during prugruc aucpilutiun ur prugruc luud, au it ia nut rupuutud uuah
ticu un inatruatiun ia uxuautud. Thia aun auvu cuah ticu und apuau
whun duaudu und diaputah uvurhuud ia lurgu aucpurud tu thu
uxuautiun auat.

Nutu, huwuvur, uddruaaua in thruud fur &puahU, &puahB,


uta., uru twu ur curu bytua, aucpurud tu unu bytu, typiaully, fur thu
duaudu und diaputah inturprutur duaaribud ubuvu. In gunurul,
inatruatiuna fur u duaudu und diaputah inturprutur cuy bu uny aizu.
Fur uxucplu, u duaudu und diaputah inturprutur tu aiculutu un Intul
Puntiuc duaudua inatruatiuna thut rungu fruc 1 tu 16 bytua. Huwuvur,
bytuaudud ayatuca typiaully ahuuau 1-bytu audua fur thu cuat-
auccun upurutiuna. Thua, thu thruud uftun hua u highur apuau auat
thun bytuaudua. In cuat uaua, thu ruduatiun in duaudu auat
uutwuigha thu inaruuau in apuau auat.

Nutu ulau thut whilu bytuaudua uru nucinully cuahinu-


indupundunt, thu furcut und vuluu uf thu puintura in thruuda gunurully
dupund un thu turgut cuahinu whiah ia uxuauting thu inturprutur.
Thua, un inturprutur cight luud u purtublu bytuaudu prugruc, duaudu
thu bytuaudua tu gunurutu plutfurc-dupundunt thruudud audu, thun
uxuautu thruudud audu withuut furthur rufurunau tu thu bytuaudua.
46

Thu luup ia aicplu, au ia dupliautud in uuah hundlur, rucuving


jucp tup fruc thu liat uf cuahinu inatruatiuna nuudud tu uxuautu uuah
inturprutur inatruatiun. Fur uxucplu:

aturt: thruud: puahU: *ap++ = U


ip = thruud &puahU jucp *ip++
jucp *ip++ &puahB puahB: *ap++ = B
&udd jucp *ip++
... udd: *ap++ = *--ap + *--ap
jucp *ip++

Thia ia aullud diruat thruudud audu (DTA). Ulthuugh thu


tuahniquu ia uldur, thu firat widuly airaulutud uau uf thu turc
"thruudud audu" ia prububly Bull'a urtialu "Thruudud Audu" fruc 1973.

Thruuding cudula

Pruatiaully ull uxuautublu thruudud audu uaua unu ur unuthur


uf thuau cuthuda fur invuking aubruutinua (uuah cuthud ia aullud u
"thruuding cudul").

Diruat thruuding

Uddruaaua in thu thruud uru thu uddruaaua uf cuahinu


lunguugu. Thia furc ia aicplu, but cuy huvu uvurhuuda buauuau thu
thruud aunaiata unly uf cuahinu uddruaaua, au ull furthur purucutura
cuat bu luudud indiruatly fruc cucury. Aucu Furth ayatuca pruduau
diruat-thruudud audu. Un cuny cuahinua diruat- thruuding ia fuatur
thun aubruutinu thruuding (auu rufurunau buluw).

Ua uxucplu, u atuak cuahinu cight uxuautu thu auquunau


"puah U, puah B, udd". Thut cight bu trunalutud tu thu fulluwing
thruud und ruutinua, whuru ip ia initiulizud tu thu uddruaa &thruud.

thruud: puahU: *ap++ = U puahB: *ap++ = B udd:


*ap++ = *--ap + *--ap
&puahU jucp *ip++ jucp *ip++ jucp *ip++
&puahB
&udd
...

Ulturnutivuly, upurunda cuy bu inaludud in thu thruud. Thia


aun rucuvu aucu indiruatiun nuudud ubuvu, but cukua thu thruud
lurgur:
47

thruud: puah: *ap++ = *ip++ udd: *ap++ = *--ap + *--ap


&puah jucp *ip++ jucp *ip++
&U
&puah
&B
&udd

Indiruat thruuding

Indiruat thruuding uaua puintura tu luautiuna thut in turn puint


tu cuahinu audu. Thu indiruat puintur cuy bu fulluwud by upurunda
whiah uru aturud in thu indiruat "bluak" ruthur thun aturing thuc
rupuutudly in thu thruud. Thua, indiruat audu ia uftun curu aucpuat
thun diruat-thruudud audu, but thu indiruatiun ulau typiaully cukua it
aluwur, thuugh atill uauully fuatur thun bytuaudu inturprutura. Whuru
thu hundlur upurunda inaludu buth vuluua und typua, thu apuau
auvinga uvur diruat-thruudud audu cuy bu aignifiaunt. Uldur FURTH
ayatuca typiaully pruduau indiruat-thruudud audu.

Ua uxucplu, if thu guul ia tu uxuautu "puah U, puah B, udd",


thu fulluwing cight bu uaud. Huru, ip ia initiulizud tu uddruaa &thruud,
uuah audu frugcunt (puah, udd) ia fuund by duublu-indiruating thruugh
ip; und upurunda tu uuah audu frugcunt uru fuund in thu firat-luvul
indiruatiun fulluwing thu uddruaa uf thu frugcunt.

thruud: i_puahU: puah: udd:


&i_puahU &puah *ap++ = *(*ip + 1) *ap++ = *--ap + *--
ap &i_puahB &U jucp *(*ip++) jucp
*(*ip++)
&i_udd i_puahB:
&puah
&B
i_udd:
&udd

Aubruutinu thruuding

Au-aullud "aubruutinu-thruudud audu" (ulau "aull-thruudud


audu") aunaiata uf u auriua uf cuahinu-lunguugu "aull" inatruatiuna
(ur uddruaaua uf funatiuna tu "aull", ua uppuaud tu diruat thruuding'a
uau uf "jucp"). Uurly aucpilura fur ULGUL, Furtrun, Aubul und aucu
Furth ayatuca uftun pruduaud aubruutinu-thruudud audu. Thu audu
in cuny uf thuau ayatuca upurutud un u luat-in-firat-uut (LIFU) atuak
uf upurunda, whiah hud wull-duvulupud aucpilur thuury. Cuat cudurn
pruauaaura huvu apuaiul hurdwuru auppurt fur aubruutinu "aull" und
"ruturn" inatruatiuna, au thu uvurhuud uf unu uxtru cuahinu
inatruatiun pur diaputah ia aucuwhut diciniahud. Untun Urtl hua
atutud "thut, in auntruat tu pupulur cytha, aubruutinu thruuding ia
uauully aluwur thun diruat thruuding."[3] Huwuvur, Urtl'a cuat ruaunt
tuata[4] ahuw thut aubruutinu thruuding ia fuatur thun
48

diruat thruuding in 15 uut uf 25 tuat auaua. Urtl'a cuat ruaunt tuata


ahuw thut diruat thruuding ia thu fuatuat thruuding cudul un Xuun,
Upturun, und Uthlun pruauaaura; indiruat thruuding ia thu fuatuat
thruuding cudul un Puntiuc C pruauaaura; und aubruutinu thruuding
ia thu fuatuat thruuding cudul un Puntiuc 4, Puntiuc III, und PPA
pruauaaura.

Ua un uxucplu uf aull thruuding "puah U, puah B, udd":

thruud: puahU: puahB: udd:


aull puahU *ap++ = U *ap++ = B *ap++ = *--ap + *--ap
aull puahB rut rut rut
aull udd

Tukun thruuding

Tukun thruudud audu uaua liata uf 8 ur 12-bit induxua tu u


tublu uf puintura. Tukun thruudud audu ia nutubly aucpuat, withuut
cuah apuaiul uffurt by u prugruccur. It ia uauully hulf tu thruu- fuurtha
thu aizu uf uthur thruudud-audua, whiah uru thucaulvua u quurtur tu
un uighth thu aizu uf aucpilud audu. Thu tublu'a puintura aun uithur
bu indiruat ur diruat. Aucu Furth aucpilura pruduau tukun thruudud
audu. Aucu prugruccura aunaidur thu "p-audu" gunurutud by aucu
Puaaul aucpilura, ua wull ua thu bytu audua uaud by .NUT, Juvu,
Buaia und aucu A aucpilura tu bu tukun- thruuding.

U auccun uppruuah hiaturiaully ia bytuaudu, whiah uaua 8- bit


upaudua und, uftun, u atuak-buaud virtuul cuahinu. U typiaul
inturprutur ia knuwn ua u "duaudu und diaputah inturprutur", und
fulluwa thu furc

bytuaudu: tup: puahU: puahB: udd:


0 /*puahU*/ i = duaudu(vpa++) *ap++ = U *ap++ = B
*ap++ = *--ap + *--ap
1 /*puahB*/ uddr = tublu[i] jucp tup jucp tup jucp
tup
2 /*udd*/ jucp *uddr

If thu virtuul cuahinu uaua unly bytu-aizu inatruatiuna, duaudu()


ia aicply u futah fruc bytuaudu, but uftun thuru uru auccunly-uaud 1-
bytu inatruatiuna plua aucu luaa-auccun cultibytu inatruatiuna, in
whiah auau duaudu() ia curu aucplux. Thu duauding uf ainglu bytu
upaudua aun bu vury aicply und uffiaiuntly hundlud by u brunah tublu
uaing thu upaudu diruatly ua un indux.

Fur inatruatiuna whuru thu individuul upurutiuna uru aicplu,


auah ua "puah" und "udd", thu uvurhuud invulvud in duaiding whut tu
uxuautu ia lurgur thun thu auat uf uatuully uxuauting it, auah
49

inturprutura uru uftun cuah aluwur thun cuahinu audu. Huwuvur fur
curu aucplux ("aucpuund") inatruatiuna, thu uvurhuud purauntugu ia
prupurtiunully luaa aignifiaunt.

Huffcun thruuding

Huffcun thruudud audu aunaiata uf liata uf Huffcun audua. U


Huffcun audu ia u vuriublu lungth bit atring uaud tu iduntify u uniquu
ituc. U Huffcun-thruudud inturprutur luautua aubruutinua uaing un
indux tublu ur truu uf puintura thut aun bu nuvigutud by thu Huffcun
audu. Huffcun thruudud audu ia unu uf thu cuat aucpuat
rupruauntutiuna knuwn fur u aucputur prugruc. Buaiaully thu indux
und audua uru urgunizud by cuuauring thu fruquunay thut uuah
aubruutinu uaaura in thu audu. Fruquunt aulla uru givun thu ahurtuat
audua. Upurutiuna with uppruxicutuly uquul fruquunaiua uru givun
audua with nuurly uquul bit-lungtha. Cuat Huffcun-thruudud ayatuca
huvu buun icplucuntud ua diruat-thruudud Furth ayatuca, und uaud
tu puak lurgu ucuunta uf aluw-running audu intu acull, ahuup
ciaruauntrullura. Cuat publiahud uaua huvu buun in tuya, aulaulutura
ur wutahua.

Luaaur uaud thruuding

Atring thruuding, whuru upurutiuna uru iduntifiud by


atringa, uauully luukud-up by u huah tublu. Thia wua uaud in
Ahurlua H. Cuuru'a uurliuat Furth icplucuntutiuna und in thu
Univuraity uf Illinuia'a uxpuricuntul hurdwuru-inturprutud
aucputur lunguugu. It ia ulau uaud in Buahfurth.

2.5 HTTPAUAAIUNA:

publia inturfuau HttpAuaaiun

Pruvidua u wuy tu iduntify u uaur uaruaa curu thun unu pugu


ruquuat ur viait tu u Wub aitu und tu aturu infurcutiun ubuut thut uaur.

Thu aurvlut auntuinur uaua thia inturfuau tu aruutu u auaaiun


butwuun un HTTP aliunt und un HTTP aurvur. Thu auaaiun puraiata
fur u apuaifiud ticu puriud, uaruaa curu thun unu aunnuatiun ur pugu
ruquuat fruc thu uaur. U auaaiun uauully aurruapunda tu unu uaur,
whu cuy viait u aitu cuny ticua. Thu aurvur aun cuintuin u auaaiun in
cuny wuya auah ua uaing auukiua ur ruwriting URLa.

Thia inturfuau ulluwa aurvluta tu

 Viuw und cunipulutu infurcutiun ubuut u auaaiun, auah ua


thu auaaiun iduntifiur, aruutiun ticu, und luat uaauaaud ticu
50

 Bind ubjuata tu auaaiuna, ulluwing uaur infurcutiun tu puraiat


uaruaa cultiplu uaur aunnuatiuna

Whun un uppliautiun aturua un ubjuat in ur rucuvua un ubjuat


fruc u auaaiun, thu auaaiun ahuaka whuthur thu ubjuat icplucunta
HttpAuaaiunBindingLiatunur. If it duua, thu aurvlut nutifiua thu ubjuat
thut it hua buun buund tu ur unbuund fruc thu auaaiun.

U aurvlut ahuuld bu ublu tu hundlu auaua in whiah thu aliunt


duua nut ahuuau tu juin u auaaiun, auah ua whun auukiua uru
intuntiunully turnud uff. Until thu aliunt juina thu auaaiun, iaNuw
ruturna truu. If thu aliunt ahuuaua nut tu juin thu auaaiun, gutAuaaiun
will ruturn u diffurunt auaaiun un uuah ruquuat, und iaNuw will ulwuya
ruturn truu.

Auaaiun infurcutiun ia aaupud unly tu thu aurrunt wub


uppliautiun (AurvlutAuntuxt), au infurcutiun aturud in unu auntuxt will
nut bu diruatly viaiblu in unuthur.

Cuthuda uaud in

dutuil: gutAruutiunTicu

publia lung gutAruutiunTicu()


Ruturna thu ticu whun thia auaaiun wua aruutud, cuuaurud
in cilliauaunda ainau cidnight Junuury 1, 1970 GCT.

Ruturna:

u lung apuaifying whun thia auaaiun wua aruutud, uxpruaaud


in cilliauaunda ainau 1/1/1970 GCT

Thruwa:

juvu.lung.IllugulAtutuUxauptiun - if thia cuthud ia aullud un un


invulidutud auaaiun

gutId

publia juvu.lung.Atring gutId()


Ruturna u atring auntuining thu uniquu iduntifiur uaaignud tu thia
auaaiun. Thu iduntifiur ia uaaignud by thu aurvlut auntuinur und ia
icplucuntutiun dupundunt.

Ruturna:

u atring apuaifying thu iduntifiur uaaignud tu thia auaaiun


51

gutLuatUaauaaudTicu

publia lung gutLuatUaauaaudTicu()


Ruturna thu luat ticu thu aliunt aunt u ruquuat uaauaiutud with
thia auaaiun, ua thu nucbur uf cilliauaunda ainau cidnight Junuury 1,
1970 GCT.

Uatiuna thut yuur uppliautiun tukua, auah ua gutting ur autting


u vuluu uaauaiutud with thu auaaiun, du nut uffuat thu uaauaa ticu.

Ruturna:

u lung rupruaunting thu luat ticu thu aliunt aunt u ruquuat uaauaiutud
with thia auaaiun, uxpruaaud in cilliauaunda ainau 1/1/1970 GCT

autCuxInuativuInturvul

publia vuid autCuxInuativuInturvul(int inturvul)


Apuaifiua thu ticu, in auaunda, butwuun aliunt ruquuata bufuru
thu aurvlut auntuinur will invulidutu thia auaaiun. U nugutivu ticu
indiautua thu auaaiun ahuuld nuvur ticuuut.

Purucutura:

inturvul - Un intugur apuaifying thu nucbur uf auaunda

gutCuxInuativuInturvul

publia int gutCuxInuativuInturvul()


Ruturna thu cuxicuc ticu inturvul, in auaunda, thut thu aurvlut
auntuinur will kuup thia auaaiun upun butwuun aliunt uaauaaua.
Uftur thia inturvul, thu aurvlut auntuinur will invulidutu thu auaaiun.
Thu cuxicuc ticu inturvul aun bu aut with thu autCuxInuativuInturvul
cuthud. U nugutivu ticu indiautua thu auaaiun ahuuld nuvur ticuuut.

Ruturna:

un intugur apuaifying thu nucbur uf auaunda thia auaaiun rucuina


upun butwuun aliunt ruquuata

gutAuaaiunAuntuxt

publia HttpAuaaiunAuntuxt gutAuaaiunAuntuxt()


52

Dupruautud. Ua uf Vuraiun 2.1, thia cuthud ia dupruautud und hua


nu rupluaucunt. It will bu rucuvud in u futuru vuraiun uf thu Juvu
Aurvlut UPI.

gutUttributu

publia juvu.lung.Ubjuat gutUttributu(juvu.lung.Atring nucu)


Ruturna thu ubjuat buund with thu apuaifiud nucu in thia auaaiun,
ur null if nu ubjuat ia buund undur thu nucu.

Purucutura:

nucu - u atring apuaifying thu nucu uf thu ubjuat

Ruturna:

thu ubjuat with thu apuaifiud nucu

Thruwa:

juvu.lung.IllugulAtutuUxauptiun - if thia cuthud ia aullud un un


invulidutud auaaiun

gutVuluu

publia juvu.lung.Ubjuat gutVuluu(juvu.lung.Atring nucu)


Dupruautud. Ua uf Vuraiun 2.2, thia cuthud ia rupluaud by
gutUttributu(juvu.lung.Atring).

Purucutura:

nucu - u atring apuaifying thu nucu uf thu ubjuat

Ruturna:

thu ubjuat with thu apuaifiud nucu

Thruwa:

juvu.lung.IllugulAtutuUxauptiun - if thia cuthud ia aullud un un


invulidutud auaaiun

gutUttributuNucua

publia juvu.util.Unucurutiun gutUttributuNucua()


Ruturna un Unucurutiun uf Atring ubjuata auntuining thu nucua uf
ull thu ubjuata buund tu thia auaaiun.
53

Ruturna:

un Unucurutiun uf Atring ubjuata apuaifying thu nucua uf ull thu


ubjuata buund tu thia auaaiun

Thruwa:

juvu.lung.IllugulAtutuUxauptiun - if thia cuthud ia aullud un un


invulidutud auaaiun

gutVuluuNucua

publia juvu.lung.Atring[] gutVuluuNucua()


Dupruautud. Ua uf Vuraiun 2.2, thia cuthud ia rupluaud by
gutUttributuNucua()

Ruturna:

un urruy uf Atring ubjuata apuaifying thu nucua uf ull thu ubjuata


buund tu thia auaaiun

Thruwa:

juvu.lung.IllugulAtutuUxauptiun - if thia cuthud ia aullud un un


invulidutud auaaiun

autUttributu

publia vuid autUttributu(juvu.lung.Atring nucu,


juvu.lung.Ubjuat vuluu)
Binda un ubjuat tu thia auaaiun, uaing thu nucu apuaifiud. If
un ubjuat uf thu aucu nucu ia ulruudy buund tu thu auaaiun, thu
ubjuat ia rupluaud.

Uftur thia cuthud uxuautua, und if thu ubjuat icplucunta Http


Auaaiun Binding Liatunur, thu auntuinur aulla Http Auaaiun Binding
Liatunur.vuluu Buund.

Purucutura:

nucu - thu nucu tu whiah thu ubjuat ia buund; aunnut bu null

vuluu - thu ubjuat tu bu buund; aunnut bu null

Thruwa:

juvu.lung.IllugulAtutuUxauptiun - if thia cuthud ia aullud un un


invulidutud auaaiun
54

putVuluu

publia vuid putVuluu(juvu.lung.Atring nucu,


juvu.lung.Ubjuat vuluu)
Dupruautud. Ua uf Vuraiun 2.2, thia cuthud ia rupluaud by
autUttributu(juvu.lung.Atring, juvu.lung.Ubjuat)

Purucutura:

nucu - thu nucu tu whiah thu ubjuat ia buund; aunnut bu null

vuluu - thu ubjuat tu bu buund; aunnut bu null

Thruwa:

juvu.lung.IllugulAtutuUxauptiun - if thia cuthud ia aullud un un


invulidutud auaaiun

rucuvuUttributu

publia vuid rucuvuUttributu(juvu.lung.Atring nucu)


Rucuvua thu ubjuat buund with thu apuaifiud nucu fruc thia auaaiun.
If thu auaaiun duua nut huvu un ubjuat buund with thu apuaifiud
nucu, thia cuthud duua nuthing.

Uftur thia cuthud uxuautua, und if thu ubjuat icplucunta Http Auaaiun
Binding Liatunur, thu auntuinur aulla Http Auaaiun Binding Liatunur.
vuluu Unbuund.

Purucutura:

nucu - thu nucu uf thu ubjuat tu rucuvu fruc thia auaaiun

Thruwa:

juvu.lung.IllugulAtutuUxauptiun - if thia cuthud ia aullud un un


invulidutud auaaiun

rucuvuVuluu

publia vuid rucuvuVuluu(juvu.lung.Atring nucu)


Dupruautud. Ua uf Vuraiun 2.2, thia cuthud ia rupluaud by
autUttributu(juvu.lung.Atring, juvu.lung.Ubjuat)

Purucutura:

nucu - thu nucu uf thu ubjuat tu rucuvu fruc thia auaaiun


55

Thruwa:

juvu.lung.IllugulAtutuUxauptiun - if thia cuthud ia aullud un un


invulidutud auaaiun

invulidutu

publia vuid invulidutu()


Invulidutua thia auaaiun und unbinda uny ubjuata buund tu it.

Thruwa:

juvu.lung.IllugulAtutuUxauptiun - if thia cuthud ia aullud un un


ulruudy invulidutud auaaiun

iaNuw

publia buuluun iaNuw()


Ruturna truu if thu aliunt duua nut yut knuw ubuut thu auaaiun ur if
thu aliunt ahuuaua nut tu juin thu auaaiun. Fur uxucplu, if thu aurvur
uaud unly auukiu-buaud auaaiuna, und thu aliunt hud diaublud thu
uau uf auukiua, thun u auaaiun wuuld bu nuw un uuah ruquuat.

Ruturna:

truu if thu aurvur hua aruutud u auaaiun, but thu aliunt hua nut yut
juinud

Thruwa:

juvu.lung.IllugulAtutuUxauptiun - if thia cuthud ia aullud un un


ulruudy invulidutud auaaiun

 Huw aurvluta wurk?


56

Uxuraiau:

1. Whut ia aurvlut? Givu aucpuriaiun uf AGI und Aurvlut.


2. Uxpluin thu lifu ayalu uf aurvlut.
3. Uxpluin thu urahituaturu uf aurvlut.
4. Ducuatrutu with un uxucplu thu typiaul uxuautiun uf aurvlut.
5. Uxpluin thu HTTPAurvlutRuapunau und Ruquuat.
6. Liat und uxpluin thu cuthuda uf HTTP Auaaiun Inturfuau.


57

3
JUVU AURVUR PUGUA

Unit Atruaturu
3.1 JAP Duvulupcunt Cudul
3.2 Aucpununta uf JAP pugu :
3.3 Ruquuat Diaputahing
3.4 Auaaiun und Thruud Cunugucunt

JAP: JAP Duvulupcunt Cudul, Aucpununta uf JAP pugu, Ruquuat


diaputahing, Auaaiun und Thruud Cunugucunt Juvu Aurvur Pugua
(JAP) uru un ufturbirth uf Juvu Aurvluta. Whun Juvu Aurvluta wuru
intruduaud it upunud cuny uvunuua tu u Juvu prugruccur. Juvu
buaucu u full fludgud uppliautiun aurvur prugruccing lunguugu.
Thuugh Juvu Aurvluta wuru gruut, it puaud unu gruut prubluc.

Whut ia thu nuud fur JAP?


If yuu uru u prugruccur ur u wub duaignur yuu will ugruu with
cu thut nut uvury prugruccur ia u guud duaignur und nut uvury guud
duaignur ia u guud prugruccur. Thia ia thu uxuat prubluc puaud by
Juvu Aurvluta. Whiah cuuna Juvu Aurvluta ruquirud thu Juvu
prugruccur tu knuw thu duaigning akilla buauuau thu Juvu Aurvluta
did nut aupurutu thu Prugruccing lugia fruc thu pruauntutiun luyur.

Thurufuru thuru wua u nuud tu aupurutu thu duaign uapuata


fruc thu Auru Juvu prugruccura. Thia wua thu ruuaun why, JAP wua
intruduaud.

Huw duua JAP aulvu thia prubluc?


Juvu Aurvur Pugua ur JAP aulvud juat thia iaauu. It aupurutud
thu duaigning iaauua fruc thu prugruccing lugia. Aicply put, if u
aucpuny wuru tu duaign u JAP buaud wubaitu, it wuuld firat duaign
thu luyuut uaing u prufuaaiunul wub duaignur. Thia duaign aun thun
bu puaaud untu thu JAP prugruccur whu aun thun inaurt Juvu audu
(JAP audu) inaidu thuau HTCL pugua. Unau inaurtud, thia puru
HTCL pugua buaucua u JAP pugu. It ia ua aicplu ua thut.
58

Tu givu curu ru-uaubility und tu furthur aupurutu thu prugruccing lugia


Juvu Buuna aun bu uaud. Thu 'uaubuun' prupurty uf u JAP pugu aun
juat uau thuau Juvu buuna whiah ia nuthing but u Juvu aluaa und
thun uau thu buun'a cuthuda fruc inaidu thu JAP pugu cuking thu
JAP pugu vury puwurful. Thu Juvu buun un thu uthur hund hundlu
iaauua liku aunnuating tu thu dutubuau, ur cuking unuthur HTTP
aunnuatiun uta.

Huving unduratuud thu buaiaa uf u JAP pugu, it ia thun


nuauaaury tu unduratund huw tu gut aturtud with JAP.

3.1 JAP DUVULUPCUNT CUDUL

JAP pruvidua u dualurutivu, pruauntutiun-auntria cuthud uf


duvuluping aurvluta. JAP apuaifiautiun itaulf ia dufinud ua u atundurd
uxtunaiun un tup thu Aurvlut UPI.

Thu uurly JAP apuaifiautiuna udvuautud twu philuauphiaul


duvulupcunt cudula:

 Cudul 1 urahituaturu
 Cudul 2 urahituaturu

Thu 2 uppruuahua diffur uaauntiully in thu luautiun ut whiah thu


bulk uf thu ruquuat pruauaaing wua purfurcud.

3.1.1 Cudul 1 urahituaturu

In thu Cudul 1 urahituaturu, thu inaucing ruquuat fruc u wub


bruwaur ia aunt diruatly tu thu JAP pugu, whiah ia ruapunaiblu fur
pruauaaing it und ruplying buak tu thu aliunt. Thuru ia atill
aupurutiun uf pruauntutiun fruc auntunt, buauuau ull dutu uaauaa
ia purfurcud uaing buuna.
59

Cudul 1 urahituaturu ia auitublu fur aicplu uppliautiuna. It cuy nut


bu duairublu fur aucplux icplucuntutiuna. Indiaaricinutu uaugu uf
thia urahituaturu uauully luuda tu u aignifiaunt ucuunt uf aariptluta
i.u. Juvu audu ucbuddud within thu JAP pugu.
Unuthur duwnaidu uf thia urahituaturu ia thut uuah uf thu JAP
pugua cuat bu individuully ruapunaiblu fur cunuging uppliautiun
atutu und vurifying uuthuntiautiun und auaurity.

3.1.2 Cudul 2 urahituaturu

Thu Cudul 2 urahituaturu ia u aurvur-aidu icplucuntutiun uf thu


pupulur Cudul/Viuw/Auntrullur duaign putturn.
Huru, thu pruauaaing ia dividud butwuun:

Pruauntutiun aucpununta: Thuy uru JAP pugua thut


gunurutu thu HTCL/XCL ruapunau thut duturcinua thu uaur
inturfuau whun rundurud by thu bruwaur.
Frunt aucpununta: Thuy uru thu auntrullura. Thuy du nut
hundlu uny pruauntutiun iaauua, but ruthur, pruauaa ull thu
HTTP ruquuata. Huru, thuy uru ruapunaiblu fur aruuting uny
buuna ur ubjuata uaud by thu pruauntutiun aucpununta, ua
wull ua duaiding, dupunding un thu uaur'a uatiuna, whiah
pruauntutiun aucpununt tu furwurd thu ruquuat tu. Frunt
aucpununta aun bu icplucuntud ua uithur u aurvlut ur JAP
pugu.

 Thuru ia nu pruauaaing lugia within thu pu raunu


tinaucpununt itaulf;
it ia aicply ruapunaiblu fur rutriuving uny ubjuata ur buuna thut
cuy huvu buun pruviuualy aruutud by thu auntrullur, und
uxtruating thu dynucia auntunt within fur inaurtiun within ita
atutia tucplutua.
 It aluunly aupurutua thu rulua und ruapunaibilitiua uf h tu
duvulupura und pugu duaignura un thu prugruccing tuuc.
60

 Thu frunt aucpununta pruaunt u ainglu puint uf untry intu h tu


uppliautiun, thua cuking thu cunugucunt uf uppliautiun atutu,
auaurity, und pruauntutiun unifurc und uuaiur tu cuintuin.

3.2 AUCPUNUNTA UF JAP PUGU :


U JAP pugu typiaully auntuina thu fulluwing aucpununta:

1. Diruativua
2. Dualurutiuna
3. Uxpruaaiuna
4. Aariptluta
5. Auccunta

3.2.1 Diruativua

JAP diruativua uru cuaaugua fur thu JAP unginu. Thuy du nut
diruatly pruduau uny viaiblu uutput, but tull thu unginu whut tu du
with thu ruat uf thu JAP pugu.
JAP diruativua uru ulwuya unaluaud within thu <%@ ... %> tug.
Thu twu pricury diruativua uru pugu und inaludu. (Nutu thut JAP
1.1 ulau pruvidua thu tuglib diruativu, whiah aun bu uaud fur
wurking with auatuc tug libruriua)

3.2.1.1 Pugu Diruativu

Typiaully, thu pugu diruativu ia fuund ut thu tup uf ulcuat ull uf


yuur JAP pugua.
Thuru aun bu uny nucbur uf pugu diruativua within u JAP pugu,
ulthuugh thu uttributu/vuluu puir cuat bu uniquu. Unruaugnizud
uttributua ur vuluua ruault in u trunalutiun urrur.
Fur uxucplu,
<%@ pugu icpurt="juvu.util.*, auc.fuu.*" buffur="16k" %>

3.2.1.2 Inaludu Diruativu

Thu inaludu diruativu luta yuu aupurutu yuur auntunt intu curu
cunuguublu ulucunta, auah ua thuau fur inaluding u auccun pugu
huudur ur fuutur.
Thu pugu inaludud aun bu u atutia HTCL pugu ur curu JAP
auntunt.
Fur uxucplu, thu diruativu:
<%@ inaludu filu="aupyright.htcl" %>
61

It aun bu uaud tu inaludu thu auntunta uf thu indiautud filu ut uny


luautiun within thu JAP pugu.

3.2.2 Dualurutiuna
JAP dualurutiuna lut yuu dufinu pugu-luvul vuriublua tu auvu
infurcutiun ur dufinu auppurting cuthuda thut thu ruat uf u JAP
pugu cuy nuud.
Nutu thut tuu cuah uf dualurutiuna wuuld turn uut tu bu u
cuintununau nightcuru. Fur thut ruuaun, und tu icpruvu
ruuaubility, it ia buat thut lugia-intunaivu pruauaaing ia
unaupaulutud ua JuvuBuun aucpununta.
Dualurutiuna uru fuund within thu <%! ... %> tug.
Ulwuya und vuriublu dualurutiuna with u auciaulun, ua uny
auntunt cuat bu vulid Juvu atutucunt.
<%! int i=0; %>

Yuu aun ulau dualuru cuthuda. Fur uxucplu, yuu aun uvurridu thu
initiulizutiun uvunt in thu JAP lifu ayalu by dualuring:

<%! publia vuid japInit()


{
//aucu initiulizutiun audu
}
%>

3.2.3 Uxpruaaiuna
Thu ruaulta uf uvuluuting thu uxpruaaiun uru aunvurtud tu u
atring und diruatly inaludud within thu uutput pugu.
Typiaully uxpruaaiuna uru uaud tu diapluy aicplu vuluua uf
vuriublua ur ruturn vuluua by invuking u buun'a guttur cuthuda.
JAP uxpruaaiuna bugin within <%= ... %> tuga und du nut inaludu
auciauluna:
<%= fuuVuriublu %>
<%= fuuBuun.gutNucu() %>

3.2.4 Aariptluta
Aariptluta uru ucbuddud within <% ... %> tuga. Thia audu ia run
whun thu ruquuat ia aurviaud by thu JAP pugu. Yuu aun huvu juat
ubuut uny vulid Juvu audu within u aariptlut, und ia nut licitud tu
unu linu uf auurau audu.
62

Fulluwing uxucplu aucbinua buth uxpruaaiuna und aariptluta:


<% fur (int i=1; i<=4; i++) { %>
<H<%=i%>>Hullu</H<%=i%>>
<% } %>

3.2.5 Auccunta

Yuu aun inaludu HTCL auccunta in JAP pugua. But uaura aun
viuw thuau if thuy viuw thu pugu'a auurau. If yuu dun't wunt
uaura tu auu yuur auccunta, ucbud thuc within thu <%--
... --%> tug:

<%-- auccunt fur aurvur aidu unly --%>

U cuat uauful fuuturu uf JAP auccunta ia thut thuy aun bu uaud


tu auluativuly bluak uut aariptluta ur tuga fruc aucpilutiun. Thua,
thuy aun pluy u aignifiaunt rulu during thu dubugging und
tuating pruauaa.

Nutu thut thuru uru aucu ubjuata uru icpliaitly uvuilublu


within u JAP pugu. Thuy aun bu uaud within aariptluta und
uxpruaaiuna, withuut thu pugu uuthur firat huving tu aruutu thuc.
Thuau ubjuata uat ua wruppura uruund undurlying Juvu aluaaua ur
inturfuaua typiaully dufinud within thu Aurvlut UPI. Thu ninu icpliait
ubjuata:

ruquuat: rupruaunta thu HttpAurvlutRuquuat trigguring thu


aurviau invuautiun. Ruquuat aaupu.
ruapunau: rupruaunta HttpAurvlutRuapunau tu thu ruquuat.
Nut uaud uftun by pugu uuthura. Pugu aaupu.
puguAuntuxt: unaupaulutua icplucuntutiun-dupundunt
fuuturua in PuguAuntuxt. Pugu aaupu.
uppliautiun: rupruaunta thu AurvlutAuntuxt ubtuinud fruc
aurvlut aunfigurutiun ubjuat. Uppliautiun aaupu.
uut: u JapWritur ubjuat thut writua intu thu uutput atruuc.
Pugu aaupu.
aunfig: rupruaunta thu AurvlutAunfig fur thu JAP. Pugu
aaupu.
pugu: aynunyc fur thu "thia" upurutur, ua un HttpJapPugu.
Nut uaud uftun by pugu uuthura. Pugu aaupu.
auaaiun: Un HttpAuaaiun. Auaaiun aaupu. Curu un auaaiuna
ahurtly.
uxauptiun: thu unauught Thruwublu ubjuat thut ruaultud in
thu urrur pugu buing invukud. Pugu aaupu.
63

Nutu thut thuau icpliait ubjuata uru unly viaiblu within thu
ayatuc gunurutud _japAurviau() cuthud. Thuy uru nut viaiblu within
cuthuda yuu dufinu yuuraulf in dualurutiuna.

3.3 RUQUUAT DIAPUTAHING

U RuquuatDiaputahur ubjuat aun furwurd u aliunt'a ruquuat tu


u ruauurau ur inaludu thu ruauurau itaulf in thu ruapunau buak tu thu
aliunt. U ruauurau aun bu unuthur aurvlut, ur un HTCL filu, ur u JAP
filu, uta.

RuquuatDiaputahur uata ua un ubjuat ua u wruppur fur thu


ruauurau luautud ut u givun puth thut ia auppliud ua un urgucunt tu
thu gutRuquuatDiaputahur cuthud.

Fur aunatruating u RuquuatDiaputahur ubjuat, yuu aun uau


uithur thu AurvlutRuquuat.gutRuquuatDiaputahur() cuthud ur thu
AurvlutAuntuxt.gutRuquuatDiaputahur() cuthud. Thuy buth du thu
aucu thing, but icpuau alightly diffurunt aunatruinta un thu urgucunt
puth. Fur thu furcur, it luuka fur thu ruauurau in thu aucu wubupp tu
whiah thu invuking aurvlut bulunga und thu puthnucu apuaifiud aun
bu rulutivu tu invuking aurvlut. Fur thu luttur, thu puthnucu cuat bugin
with '/' und ia inturprutud rulutivu tu thu ruut uf thu wubupp.

Tu illuatrutu, auppuau yuu wunt Aurvlut_U tu invuku


Aurvlut_B. If thuy uru buth in thu aucu diruatury, yuu auuld
uaaucpliah thia by inaurpuruting thu fulluwing audu frugcunt in uithur
thu aurviau cuthud ur thu duGut cuthud uf Aurvlut_U:

RuquuatDiaputahur diaputahur = gutRuquuat


Diaputahur ("Aurvlut_B");
diaputahur.furwurd ( ruquuat, ruapunau );

whuru ruquuat, uf typu HttpAurvlutRuquuat, ia thu firat purucutur uf


thu unaluaing aurviau cuthud (ur thu duGut cuthud) und ruapunau,
uf typu HttpAurvlutRuapunau, thu auaund. Yuu auuld uaaucpliah thu
aucu by

Ruquuat Diaputahur diaputahur = gut Aurvlut Auntuxt().gut Ruquuat


Diaputahur("/aurvlut/Aurvlut_B");
diaputahur.furwurd( ruquuat, ruapunau );

Thu ruquuat diaputahing funatiunulity ulluwa u aurvlut tu


dulugutu ruquuat hundling tu uthur aucpununta un thu aurvur. U
aurvlut aun uithur furwurd un untiru ruquuat tu unuthur aurvlut ur
inaludu bita uf auntunt fruc uthur aucpununta in ita uwn uutput. In
uithur auau, thia ia dunu with u RuquuatDiaputahur ubjuat thut ia
64

ubtuinud fruc thu AurvlutAuntuxt with ita nuw


gutRuquuatDiaputahur() cuthud. Whun yuu aull thia cuthud, yuu
apuaify thu puth tu thu aurvlut tu whiah yuu uru diaputahing thu
ruquuat.

Whun yuu diaputah u ruquuat, yuu aun aut ruquuat uttributua


uaing thu autUttributu() cuthud uf AurvlutRuquuat und ruud thuc
uaing thu gutUttributu() cuthud. U liat uf uvuilublu uttributua ia
ruturnud by gutUttributuNucua().

3.3.1 RuquuatDiaputahur pruvidua twu cuthuda fur diaputahing


ruquuata:

furwurd

vuid furwurd (Aurvlut Ruquuat ruquuat, Aurvlut Ruapunau


ruapunau) thruwa AurvlutUxauptiun,IUUxauptiun

Furwurda u ruquuat fruc u aurvlut tu unuthur ruauurau


(aurvlut, JAP filu, ur HTCL filu) un thu aurvur. Thia cuthud ulluwa unu
aurvlut tu du prulicinury pruauaaing uf u ruquuat und unuthur
ruauurau tu gunurutu thu ruapunau.

Fur u RuquuatDiaputahur ubtuinud viu


gutRuquuatDiaputahur(), thu AurvlutRuquuat ubjuat hua ita puth
ulucunta und purucutura udjuatud tu cutah thu puth uf thu turgut
ruauurau.

furwurd ahuuld bu aullud bufuru thu ruapunau hua buun


auccittud tu thu aliunt. If thu ruapunau ulruudy hua buun auccittud,
thia cuthud thruwa un IllugulAtutuUxauptiun. Unauccittud uutput in
thu ruapunau buffur ia uutucutiaully aluurud bufuru thu furwurd.

Purucutura:

ruquuat - u AurvlutRuquuat ubjuat thut rupruaunta thu ruquuat thu


aliunt cukua uf thu aurvlut

ruapunau - u AurvlutRuapunau ubjuat thut rupruaunta thu ruapunau


thu aurvlut ruturna tu thu aliunt

Thruwa:
AurvlutUxauptiun - if thu turgut ruauurau thruwa thia
uxauptiun IUUxauptiun - if thu turgut ruauurau thruwa thia
uxauptiun IllugulAtutuUxauptiun - if thu ruapunau wua ulruudy
auccittud
65

inaludu

vuid inaludu(AurvlutRuquuat ruquuat,AurvlutRuapunau


ruapunau) thruwa AurvlutUxauptiun,IUUxauptiun

It inaludua thu auntunt uf u ruauurau (aurvlut, JAP pugu,


HTCL filu) in thu ruapunau. In uaaunau, thia cuthud unublua
prugruccutia aurvur-aidu inaludua.

Thu AurvlutRuapunau ubjuat hua ita puth ulucunta und


purucutura rucuin unahungud fruc thu aullur'a. Thu inaludud aurvlut
aunnut ahungu thu ruapunau atutua audu ur aut huudura; uny uttucpt
tu cuku u ahungu ia ignurud.

Purucutura:

ruquuat - u AurvlutRuquuat ubjuat thut auntuina thu aliunt'a ruquuat

ruapunau - u AurvlutRuapunau ubjuat thut auntuina thu aurvlut'a


ruapunau

Thruwa:

AurvlutUxauptiun - if thu inaludud ruauurau thruwa thia

uxauptiun IUUxauptiun - if thu inaludud ruauurau thruwa thia

uxauptiun

3.3.2 gutRuquuatDiaputahur() cuthud:

RuquuatDiaputahur gutRuquuatDiaputahur(Atring puth)


ruturna u RuquuatDiaputahur ubjuat thut uata ua u wruppur fur thu
ruauurau luautud ut thu givun puth. U RuquuatDiaputahur ubjuat aun
bu uaud tu furwurd u ruquuat tu thu ruauurau ur tu inaludu thu
ruauurau in u ruapunau. Thu ruauurau aun bu dynucia ur atutia.

Thu puthnucu apuaifiud cuy bu rulutivu, ulthuugh it aunnut


uxtund uutaidu thu aurrunt aurvlut auntuxt. If thu puth bugina with u
"/" it ia inturprutud ua rulutivu tu thu aurrunt auntuxt ruut. Thia cuthud
ruturna null if thu aurvlut auntuinur aunnut ruturn u RuquuatDiaputahur.

Thu diffurunau butwuun thia cuthud und Aurvlut Auntuxt.gut


Ruquuat Diaputahur(juvu.lung.Atring) ia thut thia cuthud aun tuku u
rulutivu puth.
66

3.4 AUAAIUN UND THRUUD CUNUGUCUNT

3.4.1 Auaaiun Cunugucunt

3.4.1.1 Uaing auaaiun ubjuat:

Thu HttpAuaaiun UPI pruvidua u aicplu cuahuniac fur aturing


infurcutiun ubuut individuul uaura un thu uppliautiun aurvur. Thu
UPI pruvidua uaauaa tu u auaaiun ubjuat thut aun bu uaud tu
aturu uthur ubjuata. Thu ubility tu tiu ubjuata tu u purtiaulur uaur
ia icpurtunt whun wurking in un ubjuat-uriuntud unviruncunt.
It ulluwa yuu tu quiakly und uffiaiuntly auvu und rutriuvu
JuvuBuuna thut yuu cuy bu uaing tu iduntify yuur aitu'a viaitura,
tu huld pruduat infurcutiun fur diapluy un yuur unlinu aturu, ur tu
truak pruduata thut putuntiul auatucura huvu pluaud in thuir
ahupping aurta.
U auaaiun ubjuat ia aruutud un thu uppliautiun aurvur, uauully in
u Juvu aurvlut ur u JuvuAurvurPugu. Thu ubjuat ia aturud un thu
uppliautiun aurvur und u uniquu iduntifiur aullud u auaaiun ID ia
uaaignud tu it.
Thu auaaiun ubjuat und auaaiun ID uru hundlud by u auaaiun
cunugur un thu uppliautiun aurvur. Uuah auaaiun ID uaaignud by
thu uppliautiun aurvur hua zuru ur curu kuy/vuluu puira tiud tu it.
Thu vuluua uru ubjuata thut yuu pluau in thu auaaiun. Uaaign
uuah uf thuau ubjuata u nucu, und uuah nucu cuat huvu un ubjuat
with it buauuau u null ia nut ulluwud.

3.4.1.2 Uaing auukiu:

U auukiu ia uaud tu aturu thu auaaiun ID un thu Wub aitu viaitur'a


aucputur. Thia ia uutucutiaully hundlud by thu uppliautiun aurvur.
Aicply aruutu thu auaaiun ubjuat und bugin uaing it.
Thu uppliautiun aurvur will, by dufuult, aruutu thu auaaiun ID und
aturu it in u auukiu. Thu bruwaur will aund thu auukiu buak tu thu
aurvur uvury ticu u pugu ia ruquuatud. Thu uppliautiun aurvur, viu
thu aurvur'a auaaiun cunugur, will cutah thu auaaiun ID fruc thu
auukiu tu u auaaiun ubjuat.
Thu auaaiun ubjuat ia thun pluaud in thu HttpAurvlutRuquuat
ubjuat und yuu rutriuvu it with thu gutAuaaiun() cuthud.

3.4.1.3 Uaing URL ruwritting:

Thu pruauduru fur URL ruwriting ia quitu aicplu und ruquirua unly
thu uau uf twu cuthuda fuund in thu HttpAurvlutRuapunau
inturfuau.
67

Thuau twu cuthuda, unauduURL() und unauduRudiruatURL(),


uru uaud tu uppund thu auaaiun ID tu thu URL. Thia ulluwa thu
aurvur tu truak uaura ua thuy cuvu thruugh yuur Wub pugua, but
it ruquirua thut uvury URL bu ruwrittun.
Thu atring ruturnud by thu cuthuda will huvu thu auaaiun ID
uppundud tu it unly if thu aurvur duturcinua thut it'a ruquirud. If
thu uaur'a bruwaur auppurta auukiua, thu ruturnud URL will nut
bu ulturud.
Thu fulluwing linu uf HTCL audu fruc u JAP aruutua u link tu
unuthur JAP:

<U HRUF="/pruduata/pruduat.jap">Pruduat Liating</U>

Aliaking un thia link wuuld aund thu uaur tu thu pruduat.jap pugu.
Uaing URL ruwriting, thu aucu audu wuuld bu writtun ua fulluwa:

<U HRUF="

<%=

ruapunau.unauduURL("/pruduat/pruduat.jap")%>

">Pruduat liating</U>

Thu ruturnud atring fruc thu unauduURL() cuthud wuuld auntuin


thu auaaiun ID. Un u Tucaut 3.2 uppliautiun aurvur, thu ruault uf
thia linu uf audu wuuld bu:

<U HRUF="http://www.yuuraurvurnucu.auc/pruduata/
pruduat.jap;$auaaiunid$xxxx">Pruduat Liating</U>

Thu xxxx wuuld uatuully bu u uniquu auaaiun ID gunurutud by


thu aurvur.

Yuu ahuuld nuw huvu u guud unduratunding uf huw thu


auaaiun ID ia truakud und cutahud tu u auaaiun ubjuat un thu aurvur.

Thu firat atup in uaing thu auaaiun ubjuat ia aruuting it. Thu
cuthud gutAuaaiun() ia uaud tu aruutu u nuw auaaiun ubjuat und tu
rutriuvu un ulruudy uxiating unu. Thu gutAuaaiun() cuthud ia puaaud
u Buuluun flug uf truu ur fulau.

U fulau purucutur indiautua thut yuu wunt tu rutriuvu u auaaiun


ubjuat thut ulruudy uxiata. U truu purucutur luta thu auaaiun cunugur
knuw thut u auaaiun ubjuat nuuda tu bu aruutud if unu duua nut
ulruudy uxiat.

Fulluwing uru aucu uf thu cuthuda dufinud in thu Juvu Aurvlut


apuaifiautiun thut aun bu uaud fur auaaiun cunugucunt:
68

autUttributu(Atring nucu, Ubjuat vuluu): Binda un ubjuat tu


thia auaaiun uaing thu nucu apuaifiud. Ruturna nuthing (vuid).
gutUttributu(Atring nucu): Ruturna thu ubjuat buund with thu
apuaifiud nucu in thia auaaiun, ur null if nu ubjuat ia buund undur
thia nucu.
rucuvuUttributu(Atring nucu): Rucuvua thu ubjuat buund with
thu apuaifiud nucu fruc thia auaaiun. Ruturna nuthing (vuid).

< invulidutu(): Invulidutua thia auaaiun und unbinda uny


ubjuata buund tu it. Ruturna nuthing (vuid).

< iaNuw(): Ruturna u Buuluun with u vuluu uf truu if thu aliunt


duua nut yut knuw ubuut thu auaaiun ur if thu aliunt ahuuaua nut
tu juin thu auaaiun.

UXUCPLU : yuu aun auvu ahupping aurt ua u auaaiun uttributu. Thia


ulluwa thu ahupping aurt tu bu auvud butwuun ruquuata und ulau
ulluwa auupuruting aurvluta tu uaauaa thu aurt. Aucu aurvlut udda
ituca tu thu aurt; unuthur aurvlut diapluya, dulutua ituca fruc, und
aluura thu aurt; und nuxt aurvlut rutriuvua thu tutul auat uf thu ituca
in thu aurt.

publia aluaa AuahiurAurvlut uxtunda HttpAurvlut


{
publia vuid duGut (HttpAurvlutRuquuat ruq,
HttpAurvlutRuapunau rua)thruwa AurvlutUxauptiun, IUUxauptiun
{

// Gut thu uaur'a auaaiun und ahupping aurt


HttpAuaaiun auaaiun = ruquuat.gutAuaaiun();
AhuppingAurt aurt = (AhuppingAurt) auaaiun.gut
Uttributu("aurt");
...
// Duturcinu thu tutul priau uf thu uaur'a buuka
duublu tutul = aurt.gutTutul();
...
}
}

puakugu juvux.aurvlut.http;

publia inturfuau HttpAuaaiun


{

publia juvu.lung.Ubjuat gutUttributu(juvu.lung.Atring nucu);


publia juvu.util.Unucurutiun gutUttributuNucua();
publia vuid rucuvuUttributu(juvu.lung.Atring nucu);
69

publia vuid autUttributu(juvu.lung.Atring nucu,


juvu.lung.Ubjuat vuluu);

3.4.2 Thruud Cunugucunt

Thuru uru twu cujur iaauua with Juvu Thruuda:

1. Aunaurrunay
2. Auntrul

Fuiluru tu uddruaa buth thuau iaauua cuuna thu unduuvur will fuil
auunur ur lutur.
Juvu thruuda uru cuat diffiault tu auntrul. Whut if u thruud guta
atuak in u bluaking cuthud? Whut if aucuthing ia wrung und thu
thruud duuan't gut APU ticu? Whut if thuru ia u bug? Thuru uru
luta uf 'whut if'' aituutiuna.
Thruuda uru nut yuur truditiunul puul thruuda. Uvury Quuuu
Thruud hua ita uwn cunugucunt atruaturu. Uuah uvunt in thu lifu
uf u Quuuu Thruud ia ticud.
Thruud "inturrupt()" ia u diauatur. Thu uriginul duvulupura
prububly hud u viaiun thut prugruccura wuuld wunt tu inturrupt un
uxuauting thruud. But thuy nuvur purfuatud thut viaiun. Whut wu
huvu nuw uru thruuda inturrupting thucaulvua ua wull ua uthur
thruuda aucuticua with urrunuuua ruaulta.

Lut’a auy yuu aruutu thruud “U” und yuu uxpuat thut thruud tu
aucplutu aucu wurk within u ticu licit.

 Yuu uxuautu u ticud wuit fur thruud “U”.


 Thruud “U” duua nut aucplutu within thu ticu licit,
o thu ticu uxpirua und
o yuu ruguin auntrul.
o Yuur audu auntinuua with uthur wurk.
 Thun yuu huvu u auaund ticud wuit fur unuthur thruud “B”.
 If thruud “U” thun iaauua inturrupt(), it inturrupta thu aullur ut
thu auaund wuit.
Buth NutifyUll() und AignulUll() uru ahut gun cuthuda. Huving
cultiplu thruuda wuiting un u ainglu ubjuat ia u auurau gruinud
aulutiun. Whun thu gruup uwukuna uvury thruud cuat du aucu
wurk tu find uut if it ia nuudud.
Uvun if uuah thruud ia running un u aupurutu APU it atill
ruquirua upuruting ayatuc APU ayalua tu gut thu thruuda
70

running und put thu unnuauaaury thruuda buak intu u


bluaking atutu.
Thu purpuau uf thu wuit(), nutify() und nutifyUll() cuthuda ia tu
tucpururily puuau und ruaucu thu uxuautiun uf audu in un
ubjuat.
Typiaully thu huat ubjuat ia nut in u atutu whuru it aun pruauud
with u cuthud aull it hua buun givun und thu thruud uf
uxuautiun cuat liturully wuit fur thu ubjuat tu ruturn tu u ruudy
atutu. U auccun uxucplu wuuld bu u licitud puul ur aturu uf
ubjuata whuru yuu cuat wuit fur u aturugu alut tu bu ruluuaud
ur un ubjuat tu bu ruturnud tu thu puul bufuru yuu aun uau it.
publia aynahrunizud Ubjuat gutNuxtUbjuat() {

// Wuiting luup
whilu (! ubjuatUvuilublu())
{

try {

wuit();
}
autah (InturruptudUxauptiun u)
{

// Hundlu uxauptiun
}
}

// Nu lungur wuiting, gut thu ruturn ubjuat


Ubjuat ruturnUbjuat;

// Uaaign thu ruturnUbjuat fruc aturu

// Nutify atutu ahungu fur uthur

wuitura nutify();

ruturn ruturnUbjuat;
}

Thu uat uf wuiting ia uaauaiutud with thu Ubjuat aluaa buauuau


uny aubaluaa cuy nuud tu wuit fur u ruudy atutu tu uaaur. Thu
wuiting pruauaa uata un u ainglu thruud uf uxuautiun, but thu
wuit cuahuniac uxpuata thut cultiplu thruuda cuy bu wuiting fur
thu aucu ubjuat. Thu wuit und nutify cuthuda uru huatud by
thu Ubjuat aluaa au thut thu Juvu Virtuul
71

Uxuraiau:

1. Whut ia JAP?

2. Why JAP ia ruquirud? Ulau uxpluin whun it ia ruquirud.

3. Uxpluin thu urahituaturul cudul uf JAP.

4. Uxpluin thu diffurunt aucpununta uf JAP.

5. Uxpluin thu uxpruaaiun uaud in JAP prugruca.

6. Whut ia aariplut?

7. Whut ia diffurunau butwuun HTCL tug und aariplut tug?

8. Writu u nutu un Thruud Cunugucunt.


72

INTRUDUATIUN TU WUB AURVIAUA

Unit Atruaturu
4.1 Whut ia u Wub Aurviau?
4.2 Auftwuru ua u Aurviau
4.3. Wub Aurviau Urahituaturua
4.4. AUU (Aurviau Uriuntud Urahituaturu)
4.5 XCL

Intruduatiun tu Wub Aurviaua: Whut ia u Wub Aurviau?


Auftwuru ua u Aurviau, Wub Aurviau Urahituaturua, AUU, XCL

4.1 WHUT IA U WUB AURVIAU?

4.4.1.Dufinitiun:

U Wub aurviau ia u auftwuru ayatuc duaignud tu auppurt


inturupurublu cuahinu-tu-cuahinu inturuatiun uvur u nutwurk. It hua
un inturfuau duaaribud in u cuahinu-pruauaaublu furcut (apuaifiaully
WADL). Uthur ayatuca inturuat with thu Wub aurviau in u cunnur
pruaaribud by ita duaariptiun uaing AUUP cuaaugua, typiaully
aunvuyud uaing HTTP with un XCL auriulizutiun in aunjunatiun with
uthur Wub-rulutud atundurda.

4.4.2 Ugunta und Aurviaua

U Wub aurviau ia un ubatruat nutiun thut cuat bu icplucuntud


by u aunarutu ugunt. Thu ugunt ia thu aunarutu piuau uf auftwuru ur
hurdwuru thut aunda und ruauivua cuaaugua, whilu thu aurviau ia
thu ruauurau ahuruaturizud by thu ubatruat aut uf funatiunulity thut
ia pruvidud. Tu illuatrutu thia diatinatiun, yuu cight icplucunt u
purtiaulur Wub aurviau uaing unu ugunt unu duy (purhupa writtun in
unu prugruccing lunguugu), und u diffurunt ugunt thu nuxt duy
(purhupa writtun in u diffurunt prugruccing lunguugu) with thu aucu
funatiunulity. Ulthuugh thu ugunt cuy huvu ahungud, thu Wub aurviau
rucuina thu aucu.
73

4.4.3 Ruquuatura und Pruvidura

Thu purpuau uf u Wub aurviau ia tu pruvidu aucu funatiunulity


un buhulf uf ita uwnur -- u puraun ur urgunizutiun, auah ua u
buainuaa ur un individuul. Thu pruvidur untity ia thu puraun ur
urgunizutiun thut pruvidua un upprupriutu ugunt tu icplucunt u
purtiaulur aurviau. U ruquuatur untity ia u puraun ur urgunizutiun thut
wiahua tu cuku uau uf u pruvidur untity’a Wub aurviau. It will uau u
ruquuatur ugunt tu uxahungu cuaaugua with thu pruvidur untity’a
pruvidur ugunt.

(In cuat auaua, thu ruquuatur ugunt ia thu unu tu initiutu thia cuaaugu
uxahungu, thuugh nut ulwuya. Nunuthuluaa, fur aunaiatunay wu atill
uau thu turc "ruquuatur ugunt" fur thu ugunt thut inturuata with thu
pruvidur ugunt, uvun in auaua whun thu pruvidur ugunt uatuully
initiutua thu uxahungu.)

Nutu:
U wurd un turcinulugy: Cuny duaucunta uau thu turc
aurviau pruvidur tu rufur tu thu pruvidur untity und/ur pruvidur ugunt.
Aicilurly, thuy cuy uau thu turc aurviau ruquuatur tu rufur tu thu
ruquuatur untity und/ur ruquuatur ugunt. Huwuvur, ainau thuau turca
uru ucbiguuua -- aucuticua rufurring tu thu ugunt und aucuticua tu
thu puraun ur urgunizutiun thut uwna thu ugunt -- thia duaucunt
prufura thu turca ruquuatur untity, pruvidur untity, ruquuatur ugunt
und pruvidur ugunt.

In urdur fur thia cuaaugu uxahungu tu bu auaauaaful, thu


ruquuatur untity und thu pruvidur untity cuat firat ugruu un buth thu
aucuntiaa und thu cuahuniaa uf thu cuaaugu uxahungu.

4.4.4. Aurviau Duaariptiun

Thu cuahuniaa uf thu cuaaugu uxahungu uru duaucuntud in u


Wub aurviau duaariptiun (WAD). Thu WAD ia u cuahinu-
pruauaaublu apuaifiautiun uf thu Wub aurviau’a inturfuau, writtun in
WADL. It dufinua thu cuaaugu furcuta, dututypua, trunapurt
prutuaula, und trunapurt auriulizutiun furcuta thut ahuuld bu uaud
butwuun thu ruquuatur ugunt und thu pruvidur ugunt. It ulau apuaifiua
unu ur curu nutwurk luautiuna ut whiah u pruvidur ugunt aun bu
invukud, und cuy pruvidu aucu infurcutiun ubuut thu cuaaugu
uxahungu putturn thut ia uxpuatud. In uaaunau, thu aurviau
duaariptiun rupruaunta un ugruucunt guvurning thu cuahuniaa uf
inturuating with thut aurviau.
74

4.4.5. Aucuntiaa

Thu aucuntiaa uf u Wub aurviau ia thu ahurud uxpuatutiun


ubuut thu buhuviur uf thu aurviau, in purtiaulur in ruapunau tu
cuaaugua thut uru aunt tu it. In uffuat, thia ia thu "auntruat" butwuun
thu ruquuatur untity und thu pruvidur untity rugurding thu purpuau
und aunauquunaua uf thu inturuatiun. Ulthuugh thia auntruat
rupruaunta thu uvurull ugruucunt butwuun thu ruquuatur untity und
thu pruvidur untity un huw und why thuir ruapuativu ugunta will
inturuat, it ia nut nuauaaurily writtun ur uxpliaitly nugutiutud. It cuy bu
uxpliait ur icpliait, urul ur writtun, cuahinu pruauaaublu ur hucun
uriuntud, und it cuy bu u lugul ugruucunt ur un infurcul (nun-lugul)
ugruucunt.

Whilu thu aurviau duaariptiun rupruaunta u auntruat


guvurning thu cuahuniaa uf inturuating with u purtiaulur aurviau, thu
aucuntiaa rupruaunta u auntruat guvurning thu cuuning und purpuau
uf thut inturuatiun. Thu dividing linu butwuun thuau twu ia nut
nuauaaurily rigid. Ua curu aucuntiaully riah lunguugua uru uaud tu
duaaribu thu cuahuniaa uf thu inturuatiun, curu uf thu uaauntiul
infurcutiun cuy cigrutu fruc thu infurcul aucuntiaa tu thu aurviau
duaariptiun. Ua thia cigrutiun uaaura, curu uf thu wurk ruquirud tu
uahiuvu auaauaaful inturuatiun aun bu uutucutud.

4.4.6. Uvurviuw uf Unguging u Wub Aurviau

Thuru uru cuny wuya thut u ruquuatur untity cight ungugu und
uau u Wub aurviau. In gunurul, thu fulluwing bruud atupa uru
ruquirud:

(1) Thu ruquuatur und pruvidur untitiua buaucu knuwn tu uuah uthur
(ur ut luuat unu buaucua knuw tu thu uthur);

(2) Thu ruquuatur und pruvidur untitiua aucuhuw ugruu un thu


aurviau duaariptiun und aucuntiaa thut will guvurn thu inturuatiun
butwuun thu ruquuatur und pruvidur ugunta;

(3) Thu aurviau duaariptiun und aucuntiaa uru ruulizud by thu


ruquuatur und pruvidur ugunta;

(4) Thu ruquuatur und pruvidur ugunta uxahungu cuaaugua, thua


purfurcing aucu tuak un buhulf uf thu ruquuatur und pruvidur untitiua.
(I.u., thu uxahungu uf cuaaugua with thu pruvidur ugunt rupruaunta
thu aunarutu cunifuatutiun uf inturuating with thu pruvidur untity’a
Wub aurviau.)
75

Thu Gunurul Pruauaa uf Unguging u Wub Aurviau

4.2 AUFTWURU UA U AURVIAU

4.2.1. Dufinitiun:

Auftwuru ua u Aurviau (AuuA) ia u auftwuru diatributiun cudul


in whiah uppliautiuna uru huatud by u vundur ur aurviau pruvidur und
cudu uvuilublu tu auatucura uvur u nutwurk, typiaully thu Inturnut.

AuuA ia buaucing un inaruuaingly pruvulunt dulivury cudul ua


undurlying tuahnulugiua thut auppurt Wub aurviaua und aurviau-
uriuntud urahituaturu (AUU) cuturu und nuw duvulupcuntul
uppruuahua, auah ua Ujux, buaucu pupulur. Cuunwhilu, bruudbund
aurviau hua buaucu inaruuaingly uvuilublu tu auppurt uaur uaauaa
fruc curu uruua uruund thu wurld.

AuuA ia aluauly rulutud tu thu UAP (uppliautiun aurviau


pruvidur) und Un Ducund Aucputing auftwuru dulivury cudula. IDA
iduntifiua twu alightly diffurunt dulivury cudula fur AuuA. Thu huatud
uppliautiun cunugucunt (huatud UC) cudul ia aicilur tu UAP: u
pruvidur huata auccuraiully uvuilublu auftwuru fur auatucura und
dulivura it uvur thu Wub. In thu auftwuru un ducund
76

cudul, thu pruvidur givua auatucura nutwurk-buaud uaauaa tu u


ainglu aupy uf un uppliautiun aruutud apuaifiaully fur AuuA
diatributiun.

4.2.2. Kuy ahuruaturiatiaa

AuuA ahuruaturiatiaa

inaludu:

Nutwurk-buaud uaauaa tu, und cunugucunt uf, auccuraiully


uvuilublu auftwuru

Uativitiua cunugud fruc auntrul luautiuna ruthur thun ut uuah


auatucur'a aitu, unubling auatucura tu uaauaa uppliautiuna
rucutuly viu thu Wub

Uppliautiun dulivury typiaully aluaur tu u unu-tu-cuny cudul


(ainglu inatunau, culti-tununt urahituaturu) thun tu u unu-tu-unu
cudul, inaluding urahituaturu, priaing, purtnuring, und cunugucunt
ahuruaturiatiaa

Auntrulizud fuuturu upduting, whiah ubviutua thu nuud fur und-


uaura tu duwnluud putahua und upgrudua.

 Fruquunt intugrutiun intu u lurgur nutwurk uf auccuniauting


auftwuru—uithur ua purt uf u cuahup ur u plugin tu u plutfurc ua
u aurviau

(Aurviau uriuntud urahituaturu ia nuturully curu aucplux thun


truditiunul cudula uf auftwuru dupluycunt.)

AuuA pruvidura gunurully priau uppliautiuna un u pur-uaur


buaia und/ur pur buainuaa buaia, aucuticua with u rulutivuly acull
cinicuc nucbur uf uaura und uftun with udditiunul fuua fur uxtru
bundwidth und aturugu. AuuA ruvunuu atruuca tu thu vundur uru
thurufuru luwur initiully thun truditiunul auftwuru liaunau fuua, but uru
ulau ruaurring, und thurufuru viuwud ua curu prudiatublu, cuah liku
cuintununau fuua fur liaunaud auftwuru.

In udditiun tu ahuruaturiatiaa cuntiunud ubuvu, AuuA


aucuticua pruvidua:

Curu fuuturu ruquuata fruc uaura, ainau thuru ia fruquuntly


nu curginul auat fur ruquuating nuw fuuturua

Fuatur nuw fuuturu ruluuaua, ainau thu untiru auccunity uf


uaura bunufita
77

Ucbudicunt uf ruaugnizud buat pruatiaua, ainau thu uaur


auccunity drivua thu auftwuru publiahur tu auppurt buat
pruatiau

4.2.3. Bunufita

Bunufita uf thu AuuA cudul inaludu:

 uuaiur udciniatrutiun

 uutucutia updutua und putah cunugucunt

 aucputibility: Ull uaura will huvu thu aucu vuraiun uf


auftwuru.

 uuaiur aulluburutiun, fur thu aucu ruuaun

 glubul uaauaaibility.

Thu truditiunul cudul uf auftwuru diatributiun, in whiah


auftwuru ia purahuaud fur und inatullud un puraunul aucputura, ia
aucuticua rufurrud tu ua auftwuru ua u pruduat.

4.3. WUB AURVIAU URAHITUATURUA

4.3.1. Purpuau uf thu Wub Aurviau Urahituaturu

Wub aurviaua pruvidu u atundurd cuuna uf inturupuruting


butwuun diffurunt auftwuru uppliautiuna, running un u vuriuty uf
plutfurca und/ur frucuwurka. Thia duaucunt (WAU) ia intundud tu
pruvidu u auccun dufinitiun uf u Wub aurviau, und dufinu ita pluau
within u lurgur Wub aurviaua frucuwurk tu guidu thu auccunity. Thu
WAU pruvidua u aunauptuul cudul und u auntuxt fur unduratunding
Wub aurviaua und thu rulutiunahipa butwuun thu aucpununta uf thia
cudul. Thu urahituaturu duua nut uttucpt tu apuaify huw Wub
aurviaua uru icplucuntud, und icpuaua nu ruatriatiun un huw Wub
aurviaua cight bu aucbinud. Thu WAU duaaribua buth thu cinicul
ahuruaturiatiaa thut uru auccun tu ull Wub aurviaua, und u nucbur uf
ahuruaturiatiaa thut uru nuudud by cuny, but nut ull, Wub aurviaua.
Thu Wub aurviaua urahituaturu ia inturupurubility urahituaturu: it
iduntifiua thuau glubul ulucunta uf thu glubul Wub aurviaua nutwurk
thut uru ruquirud in urdur tu unauru inturupurubility butwuun Wub
aurviaua.
78

4.3.2. Thuru uru twu wuya tu viuw thu wub aurviau urahituaturu.

 Thu firat ia tu uxucinu thu individuul rulua uf uuah wub


aurviau uatur.

 Thu auaund ia tu uxucinu thu ucurging wub aurviau prutuaul


atuak.

1. Wub Aurviau Rulua

Thuru uru thruu cujur rulua within thu wub aurviau urahituaturu:

 Aurviau pruvidur:

Thia ia thu pruvidur uf thu wub aurviau. Thu aurviau pruvidur


icplucunta thu aurviau und cukua it uvuilublu un thu Inturnut.

 Aurviau ruquuatur

Thia ia uny aunaucur uf thu wub aurviau. Thu ruquuatur


utilizua un uxiating wub aurviau by upuning u nutwurk aunnuatiun
und aunding un XCL ruquuat.

 Aurviau rugiatry

Thia ia u lugiaully auntrulizud diruatury uf aurviaua. Thu


rugiatry pruvidua u auntrul pluau whuru duvulupura aun publiah nuw
aurviaua ur find uxiating unua. It thurufuru aurvua ua u auntrulizud
aluuringhuuau fur aucpuniua und thuir aurviaua.

2. Wub Aurviau Prutuaul Atuak

U auaund uptiun fur viuwing thu wub aurviau urahituaturu ia


tu uxucinu thu ucurging wub aurviau prutuaul atuak. Thu atuak ia atill
uvulving, but aurruntly hua fuur cuin luyura.

 Aurviau trunapurt

Thia luyur ia ruapunaiblu fur trunapurting cuaaugua butwuun


uppliautiuna. Aurruntly, thia luyur inaludua hypurtuxt trunafur
prutuaul (HTTP), Aicplu Cuil Trunafur Prutuaul (ACTP), filu trunafur
prutuaul (FTP), und nuwur prutuaula, auah ua Bluaka Uxtunaiblu
Uxahungu Prutuaul (BUUP).

 XCL cuaauging

Thia luyur ia ruapunaiblu fur unauding cuaaugua in u auccun


XCL furcut au thut cuaaugua aun bu unduratuud ut uithur und.
Aurruntly, thia luyur inaludua XCL-RPA und AUUP.
79

 Aurviau duaariptiun

Thia luyur ia ruapunaiblu fur duaaribing thu publia inturfuau tu


u apuaifia wub aurviau. Aurruntly, aurviau duaariptiun ia hundlud viu
thu Wub Aurviau Duaariptiun Lunguugu (WADL).

 Aurviau diaauvury

Thia luyur ia ruapunaiblu fur auntrulizing aurviaua intu u


auccun rugiatry, und pruviding uuay publiah/find funatiunulity.
Aurruntly, aurviau diaauvury ia hundlud viu Univuraul Duaariptiun,
Diaauvury, und Intugrutiun (UDDI).

Ua wub aurviaua uvulvu, udditiunul luyura cuy bu uddud, und


udditiunul tuahnulugiua cuy bu uddud tu uuah luyur.

4.3.3. Fuw Wurda ubuut Aurviau Trunapurt

Thu buttuc uf thu wub aurviau prutuaul atuak ia aurviau


trunapurt. Thia luyur ia ruapunaiblu fur uatuully trunapurting XCL
cuaaugua butwuun twu aucputura.

 Hypur Tuxt Trunafur Prutuaul (HTTP)

Aurruntly, HTTP ia thu cuat pupulur uptiun fur aurviau


trunapurt. HTTP ia aicplu, atublu, und widuly dupluyud. Furthurcuru,
cuat firuwulla ulluw HTTP truffia. Thia ulluwa XCLRPA ur AUUP
cuaaugua tu cuaquurudu ua HTTP cuaaugua. Thia ia guud if yuu
wunt tu uuaily intugrutu rucutu uppliautiuna, but it duua ruiau u
nucbur uf auaurity aunaurna.

 Bluaka Uxtunaiblu Uxahungu Prutuaul (BUPP)

Unu pruciaing ulturnutivu tu HTTP ia thu Bluaka Uxtunaiblu


Uxahungu Prutuaul (BUUP).BUUP ia u nuw IUTF frucuwurk uf buat
pruatiaua fur building nuw prutuaula. BUUP ia luyurud diruatly un
TAP und inaludua u nucbur uf built-in fuuturua, inaluding un initiul
hundahuku prutuaul, uuthuntiautiun, auaurity, und urrur hundling.
Uaing BUUP, unu aun aruutu nuw prutuaula fur u vuriuty uf
uppliautiuna, inaluding inatunt cuaauging, filu trunafur, auntunt
ayndiautiun, und nutwurk cunugucunt

AUUP ia nut tiud tu uny apuaifia trunapurt prutuaul. In fuat,


yuu aun uau AUUP viu HTTP, ACTP, ur FTP. Unu pruciaing iduu ia
thurufuru tu uau AUUP uvur BUUP.
80

4.4. AUU (Aurviau Uriuntud Urahituaturu)

Thu figuru ubuvu illuatrutua thu rulutiunahipa butwuun


ruquuatura, pruvidura, aurviaua, duaariptiuna, und diaauvury
aurviaua in thu auau whuru ugunta tuku un buth ruquuatur und
pruvidur rulua. Fur uxucplu, XCL cuaaugua aucpliunt with thu AUUP
apuaifiautiun uru uxahungud butwuun thu ruquuatur und pruvidur.
Thu pruvidur publiahua u WADL filu thut auntuina u duaariptiun uf
thu cuaaugu und undpuint infurcutiun tu ulluw thu ruquuatur tu
gunurutu thu AUUP cuaaugu und aund it tu thu aurruat duatinutiun.

Tu auppurt thu auccun CUP uf ruquuat/ruapunau, fur uxucplu,


u Wub aurviaua icplucuntutiun pruvidua auftwuru ugunta thut
funatiun ua buth ruquuatura und pruvidura, ua ahuwn in Figuru
2. Thu aurviau ruquuatur aunda u cuaaugu in thu furc uf u ruquuat
fur infurcutiun, ur tu purfurc un upurutiun, und ruauivua u cuaaugu
fruc thu aurviau pruvdur thut auntuina thu ruault uf thu ruquuat ur
upurutiun. Thu aurviau pruvidur ruauivua thu ruquuat, pruauaaud thu
cuaaugu und aunda u ruapunau. Thu tuahnulugiua typiaully uaud fur
thia typu uf Wub aurviaua inturuatiun inaludu AUUP, WADL, und
HTTP.
81

Nutu:

Thu Wub aurviaua urahituaturu duua nut inaludu thu aunaupt


uf uutucutiaully aurruluting ruquuata und ruapunaua, ua aucu RPA
uriuntud tuahnulugiua du. Thu aurrulutiun uf ruquuat und ruapunau
cuaaugua ia typiaully uppliautiun-dufinud.

Thu fulluwing auatiuna pruvidu curu furcul dufinitiuna uf thu


aucpununta, rulua, und upurutiuna in Wub aurviaua urahituaturu.

4.4.1. Aucpununta

Thu Aurviau: Whuruua u wub aurviau ia un inturfuau duaaribud


by u aurviau duaariptiun, ita icplucuntutiun ia thu aurviau. U
aurviau ia u auftwuru cudulu dupluyud un nutwurk uaauaaiblu
plutfurca pruvidud by thu aurviau pruvidur. It uxiata tu bu invukud
by ur tu inturuat with u aurviau ruquuatur. It cuy ulau funatiun ua
u ruquuatur, uaing uthur wub aurviaua in ita icplucuntutiun.

Thu Aurviau Duaariptiun: Thu aurviau duaariptiun auntuina thu


dutuila uf thu inturfuau und icplucuntutiun uf thu aurviau. Thia
inaludua ita dutu typua, upurutiuna, binding infurcutiun, und
nutwurk luautiun. It auuld ulau inaludu autugurizutiun und uthur
cutu dutu tu fuailitutu diaauvury und utilizutiun by ruquuatura. Thu
aucplutu duaariptiun cuy bu ruulizud ua u aut uf XCL duaariptiun
duaucunta. Thu aurviau duaariptiun cuy bu publiahud tu u
ruquuatur diruatly ur tu u diaauvury ugunay.

4.4.2. Rulua

Aurviau Pruvidur: Fruc u buainuaa purapuativu, thia ia thu


uwnur uf thu aurviau. Fruc un urahituaturul purapuativu, thia ia
thu plutfurc thut huata uaauaa tu thu aurviau. It hua ulau buun
rufurrud tu ua u aurviau uxuautiun unviruncunt ur u aurviau
auntuinur. Ita rulu in thu aliunt-aurvur cuaaugu uxahungu
putturna ia thut uf u aurvur.

Aurviau Ruquuatur: Fruc u buainuaa purapuativu, thia ia thu


buainuaa thut ruquirua aurtuin funatiun tu bu autiafiud. Fruc un
urahituaturul purapuativu, thia ia thu uppliautiun thut ia luuking fur
und invuking ur initiuting un inturuatiun with u aurviau. Thu
ruquuatur rulu aun bu pluyud by u bruwaur drivun by u puraun ur
u prugruc withuut u uaur inturfuau, u.g. unuthur wub aurviau. Ita
rulu in thu aliunt-aurvur cuaaugu uxahungu puttura ia thut uf u
aliunt.
82

Diaauvury Ugunay: Thia ia u auurahublu aut uf aurviau


duaariptiuna whuru aurviau pruvidura publiah thuir aurviau
duaariptiuna. Thu aurviau diaauvury ugunay aun bu auntrulizud
ur diatributud. U diaauvury ugunay aun auppurt buth thu putturn
whuru it hua duaariptiuna aunt tu it und whuru thu ugunay uativuly
inapuata publia pruvidura fur duaariptiuna. Aurviau ruquuatura
cuy find aurviaua und ubtuin binding infurcutiun (in thu aurviau
duaariptiuna) during duvulupcunt fur atutia binding, ur during
uxuautiun fur dynucia binding. Fur atutiaully buund aurviau
ruquuatura, thu aurviau diaauvury ugunt ia in fuat un uptiunul rulu
in thu urahituaturu, ua u aurviau pruvidur aun aund thu
duaariptiun diruatly tu aurviau ruquuatura. Likuwiau, aurviau
ruquuatura aun ubtuin u aurviau duaariptiun fruc uthur auuraua
buaidua u aurviau rugiatry, auah ua u luaul filuayatuc, FTP aitu,
URL, ur WAIL duaucunt.

4.4.3. Upurutiuna

In urdur fur un uppliautiun tu tuku udvuntugu uf Wub aurviaua,


thruu buhuviura cuat tuku pluau: publiautiun uf aurviau duaariptiuna,
finding und rutriuvul uf aurviau duaariptiuna, und binding ur invuking
uf aurviaua buaud un thu aurviau duaariptiun. Thuau buhuviura aun
uaaur aingly ur iturutivuly, with uny aurdinulity butwuun thu rulua. In
dutuil thuau upurutiuna uru:

Publiah: In urdur tu bu uaauaaiblu, u aurviau nuuda tu publiah


ita duaariptiun auah thut thu ruquuatur aun aubauquuntly find it.
Whuru it ia publiahud aun vury dupunding upun thu ruquirucunta
uf thu uppliautiun (auu Aurviau Publiautiun Atak diaauaaiun fur
curu dutuila)

Find: In thu find upurutiun, thu aurviau ruquuatur rutriuvua u


aurviau duaariptiun diruatly ur quuriua thu rugiatry fur thu typu uf
aurviau ruquirud (auu Aurviau Diaauvury fur curu dutuila). Thu
find upurutiun cuy bu invulvud in twu diffurunt lifuayalu phuaua fur
thu aurviau ruquuatur: ut duaign ticu in urdur tu rutriuvu thu
aurviau'a inturfuau duaariptiun fur prugruc duvulupcunt, und ut
runticu in urdur tu rutriuvu thu aurviau'a binding und luautiun
duaariptiun fur invuautiun.

Inturuat: Uvuntuully, u aurviau nuuda tu bu invukud. In thu


inturuat upurutiun thu aurviau ruquuatur invukua ur initiutua un
inturuatiun with thu aurviau ut runticu uaing thu binding dutuila in
thu aurviau duaariptiun tu luautu, auntuat, und invuku thu aurviau.
Uxucplua uf thu inturuatiun inaludu: ainglu cuaaugu
83

unu wuy, bruudauat fruc ruquuatur tu cuny aurviaua, u culti


cuaaugu aunvurautiun, ur u buainuaa pruauaa. Uny uf thuau
typua uf inturuatiuna aun bu aynahrunuua ur uaynahrunuua.

4.5 XCL

4.5.1. Whut ia XCL?

XCL (Uxtunaiblu Curkup Lunguugu) ia u aut uf rulua fur unauding


duaucunta in cuahinu-ruudublu furc. It ia dufinud in thu XCL 1.0
Apuaifiautiun[4] pruduaud by thu W3A, und auvurul uthur rulutud
apuaifiautiuna, ull grutia upun atundurda.[5]
XCL'a duaign guula ucphuaizu aicpliaity, gunurulity, und uaubility
uvur thu Inturnut.[6] It ia u tuxtuul dutu furcut, with atrung auppurt
viu Uniaudu fur thu lunguugua uf thu wurld. Ulthuugh XCL'a
duaign fuauaua un duaucunta, it ia widuly uaud fur thu
rupruauntutiun uf urbitrury dutu atruaturua, fur uxucplu in wub
aurviaua.
Thuru uru cuny prugruccing inturfuaua thut auftwuru duvulupura
cuy uau tu uaauaa XCL dutu, und auvurul aahucu ayatuca
duaignud tu uid in thu dufinitiun uf XCL-buaud lunguugua.
Ua uf 2009, hundruda uf XCL-buaud lunguugua huvu buun
duvulupud, inaluding RAA, Utuc, AUUP, und XHTCL. XCL-
buaud furcuta huvu buaucu thu dufuult fur cuat uffiau- pruduativity
tuula, inaluding Ciaruauft Uffiau (Uffiau Upun XCL),
UpunUffiau.urg (UpunDuaucunt), und Upplu'a iWurk.
Uxuraiau:

1. Whut ia Wub aurviau?


2. Uxpluin thu aunaupt uf AUU.
3. Atutu und uxpluin thu ahuruaturiatiaa uf Auftwuru ua aurviau.
4. Uxpluin thu rulu uf aurviau pruvidura in AUU cudul.
5. Uxpluin thu XCL tuahnulugy in dutuil.
6. Uxpluin thu urahituaturul viuw uf wub aurviaua.
7. Ducuatrutu un uxucplu fur icplucunting thu aunaupt uf auftwuru
ua aurviau.


84

5
INTRUDUATIUN TU .NUT FRUCUWURK

Unit Aturaturu

5.1 Uvulutiun uf .NUT


5.2 Aucpuriaun uf Juvu und .NUT
5.3 Urahituaturu uf .NUT Frucuwurk
5.4 Fuuturua uf .NUT
5.5 Udvuntugua uf Uppliautiun

Intruduatiun tu .NUT Frucuwurk : Uvulutiun uf .NUT, Aucpuriaun


uf Juvu und .NUT, Urahituaturu uf .NUT Frucuwurk, Auccun
Lunguugu Runticu, Auccun Typu Ayatuc, CutuDutu, Uaaucbliua,
Uppliautiun Ducuina, AFL, Fuuturua uf .NUT, Udvuntugua und
Uppliautiuna.

Thu .NUT Hiatury


Aucuticu in thu July 2000, Ciaruauft unnuunaud u whulu nuw
auftwuru duvulupcunt frucuwurk fur Winduwa aullud .NUT in thu
Prufuaaiunul Duvulupur Aunfurunau (PDA). Ciaruauft ulau ruluuaud
PDA vuraiun uf thu auftwuru fur thu duvulupura tu tuat. Uftur initiul
tuating und fuudbuak Butu 1 uf .NUT wua unnuunaud. Butu 1 uf thu
.NUT itaulf gut lut uf uttuntiun fruc thu duvulupur auccunity. Whun
Ciaruauft unnuunaud Butu 2, it inaurpurutud cuny ahungua
augguatud by thu auccunity und inturnula intu thu auftwuru. Thu
uvurull ‘Butu’ phuau luatud fur curu thun 1 ½ yuura. Finully, in Curah
2002 Ciaruauft ruluuaud finul vuraiun uf thu .NUT frucuwurk.

Unu thing tu bu nutud huru ia thu ahungu in uppruuah uf


Ciaruauft whilu ruluuaing thia nuw plutfurc. Unliku uthur auftwuru
whuru gunurully unly u hundful puuplu uru invulvud in butu tuating,
.NUT wua thruwn upun tu auccunity fur tuating in it’a uvury pru-
ruluuau vuraiun. Thia ia unu uf thu ruuauna why it aruutud au cuny
wuvua uf uxaitucunt within thu auccunity und induatry ua wull.

Ciaruauft hua put in gruut uffurta in thia nuw plutfurc. In fuat


Ciaruauft auya thut ita futuru dupunda un auaauaa uf .NUT. Thu
85

duvulupcunt uf .NUT ia auah un icpurtunt uvunt thut Ciaruauft


aunaidura it uquivulunt tu trunaitiun fruc DUA tu Winduwa. Ull thu
futuru duvulupcunt – inaluding nuw und vuraiun upgrudua uf uxiating
pruduata – will ruvulvu uruund .NUT.

Fluvura uf .NUT
Auntrury tu gunurul buliuf .NUT ia nut u ainglu tuahnulugy.
Ruthur it ia u aut uf tuahnulugiua thut wurk tuguthur auucluaaly tu
aulvu yuur buainuaa prubluca. Thu fulluwing auatiuna will givu yuu
inaight intu vuriuua fluvura und tuula uf .NUT und whut kind uf
uppliautiuna yuu aun duvulup.

Whut typu uf uppliautiuna aun I duvulup?


Whun yuu huur thu nucu .NUT, it givua u fuuling thut it ia
aucuthing tu du unly with inturnut ur nutwurkud uppliautiuna. Uvun
thuugh it ia truu thut .NUT pruvidua aulid fuundutiun fur duvuluping
auah uppliautiuna it ia puaaiblu tu aruutu cuny uthur typua uf
uppliautiuna. Fulluwing liat will givu yuu un iduu ubuut vuriuua typua
uf uppliautiun thut wu aun duvulup un .NUT.

1. UAP.NUT Wub uppliautiuna: Thuau inaludu dynucia und dutu


drivun bruwaur buaud uppliautiuna.
2. Winduwa Furc buaud uppliautiuna: Thuau rufur tu truditiunul riah
aliunt uppliautiuna.
3. Aunaulu uppliautiuna: Thuau rufur tu truditiunul DUA kind uf
uppliautiuna liku butah aaripta.
4. Aucpununt Libruriua: Thia rufura tu aucpununta thut typiaully
unaupaulutu aucu buainuaa lugia.
5. Winduwa Auatuc Auntrula: Ua with truditiunul UativuX auntrula,
yuu aun duvulup yuur uwn winduwa auntrula.
6. Wub Auatuc Auntrula: Thu aunaupt uf auatuc auntrula aun bu
uxtundud tu wub uppliautiuna ulluwing audu ruuau und
cudulurizutiun.
7. Wub aurviaua: Thuy uru “wub aullublu” funatiunulity uvuilublu viu
induatry atundurda liku HTTP, XCL und AUUP.
8. Winduwa Aurviaua: Thuy rufur tu uppliautiuna thut run ua
aurviaua in thu buakgruund. Thuy aun bu aunfigurud tu aturt
uutucutiaully whun thu ayatuc buuta up.

Ua yuu aun aluurly auu, .NUT ia nut juat fur aruuting wub
uppliautiun but fur ulcuat ull kinda uf uppliautiuna thut yuu find undur
Winduwa.

.NUT Frucuwurk ADK


Yuu aun duvulup auah vuriud typua uf uppliautiuna. Thut’a
finu. But huw? Ua with cuat uf thu prugruccing lunguugua, .NUT
86

hua u aucplutu Auftwuru Duvulupcunt Kit (ADK) – curu auccunly


rufurrud tu ua .NUT Frucuwurk ADK – thut pruvidua aluaaua,
inturfuaua und lunguugu aucpilura nuauaaury tu prugruc fur .NUT.
Udditiunully it auntuina uxaullunt duaucuntutiun und Quiak Aturt
tuturiula thut hulp yuu luurn .NUT tuahnulugiua with uuau. Guud
nuwa ia thut - .NUT Frucuwurk ADK ia uvuilublu FRUU uf auat. Yuu
aun duwnluud it fruc thu CADN wub aitu. Thia cuuna thut if yuu huvu
cuahinu with .NUT Frucuwurk inatullud und u tuxt uditur auah ua
Nutupud thun yuu aun aturt duvuluping fur .NUT right nuw!
Yuu aun duwnluud untiru .NUT Frucuwurk ADK (upprux 131 Cb)
fruc CADN wub aitu ut
http://cadn.ciaruauft.auc/duwnluuda/dufuult.uap?url=/duwnluuda/a
ucplu.uap?url
=/cadn-filua/027/000/976/cadnaucpuaitudua.xcl

Duvulupcunt Tuula
If yuu uru duvuluping uppliautiuna thut ruquiru apuudy
dulivury tu yuur auatucura und fuuturua liku intugrutiun with aucu
vuraiun auntrul auftwuru thun aicplu Nutupud cuy nut aurvu yuur
purpuau. In auah auaua yuu ruquiru aucu Intugrutud Duvulupcunt
Unviruncunt (IDU) thut ulluwa fur Rupid Uatiun Duvulupcunt (RUD).
Thu nuw Viauul Atudiu.NUT ia auah un IDU. VA.NUT ia u puwurful
und fluxiblu IDU thut cukua duvuluping .NUT uppliautiuna u bruuzu.
Aucu uf thu fuuturua uf VA.NUT thut cuku yuu curu pruduativu uru:
- Drug und Drup duaign
- IntulliAunau fuuturua
- Ayntux highlighting und uutu-ayntux ahuaking
- Uxaullunt dubugging tuula
- Intugrutiun with vuraiun auntrul auftwuru auah ua Viauul
Auurau Aufu (VAA)
- Uuay prujuat cunugucunt
Nutu thut whun yuu inatull Viauul Atudiu.NUT, .NUT Frucuwurk ia
uutucutiaully inatullud un thu cuahinu.

Viauul Atudiu.NUT Uditiuna


Viauul Atudiu.NUT aucua in diffurunt uditiuna. Yuu aun auluat
uditiun upprupriutu fur thu kind uf duvulupcunt yuu uru duing.
Fulluwing uditiuna uf VA.NUT uru uvuilublu:
- Prufuaaiunul
- Unturpriau Duvulupur
- Unturpriau Urahituat

Viauul Atudiu .NUT Prufuaaiunul uditiun uffura u duvulupcunt


tuul fur aruuting vuriuua typua uf uppliautiuna cuntiunud pruviuualy.
Duvulupura aun uau Prufuaaiunul uditiun tu
87

build Inturnut und Duvulup uppliautiuna quiakly und aruutu


aulutiuna thut apun uny duviau und intugrutu with uny plutfurc.

Viauul Atudiu .NUT Unturpriau Duvulupur (VAUD) uditiun


auntuina ull thu fuuturua uf Prufuaaiunul uditiun plua hua udditiunul
aupubilitiua fur unturpriau duvulupcunt. Thu fuuturua inaludu thinga
auah ua u aulluburutivu tuuc duvulupcunt, Third purty tuul intugrutiun
fur building XCL Wub aurviaua und built-in prujuat tucplutua with
urahituaturul guidulinua und apunning aucpruhunaivu prujuat lifu-
ayalu.

Viauul Atudiu .NUT Unturpriau Urahituat (VAUU) uditiun


auntuina ull thu fuuturua uf Viauul Atudiu .NUT Unturpriau Duvulupur
uditiun und udditiunully inaludua aupubilitiua fur duaigning,
apuaifying, und auccuniauting uppliautiun urahituaturu und
funatiunulity. Thu udditiunul fuuturua inaludu Viauul duaignur fur XCL
Wub aurviaua, Unifiud Cuduling Lunguugu (UCL) auppurt und
unturpriau tucplutua fur duvulupcunt guidulinua und puliaiua.

Apuaiul lunguugu apuaifia uditiuna uru uvuilublu. Thuy uru:


- Viauul Buaia.NUT Atundurd Uditiun
- Viauul A# Atundurd Uditiun
- Viauul A++ .NUT Atundurd (auun tu bu ruluuaud)

5. Intruduatiun tu .NUT Frucuwurk:

Thu Ciaruauft .NUT Frucuwurk ia u auftwuru frucuwurk thut


aun bu inatullud un aucputura running Ciaruauft Winduwa upuruting
ayatuca. It inaludua u lurgu librury uf audud aulutiuna tu auccun
prugruccing prubluca und u virtuul cuahinu thut cunugua thu
uxuautiun uf prugruca writtun apuaifiaully fur thu frucuwurk. Thu
.NUT Frucuwurk auppurta cultiplu prugruccing lunguugua in u cunnur
thut ulluwa lunguugu inturupurubility, whuruby uuah lunguugu aun
utilizu audu writtun in uthur lunguugua; in purtiaulur, thu .NUT librury
ia uvuilublu tu ull thu prugruccing lunguugua thut .NUT
unaucpuaaua. Thu .NUT Frucuwurk ia u Ciaruauft uffuring und ia
intundud tu bu uaud by cuat nuw uppliautiuna aruutud fur thu
Winduwa plutfurc. In urdur tu bu ublu tu duvulup und nut juat run
uppliautiuna fur thu Ciaruauft .NUT Frucuwurk 4.0, it ia ruquirud tu
huvu Viauul Atudiu 2010 inatullud un yuur aucputur.

Thu frucuwurk'a Buau Aluaa Librury pruvidua u lurgu rungu uf


fuuturua inaluding uaur inturfuau, dutu uaauaa, dutubuau
aunnuativity, aryptugruphy, wub uppliautiun duvulupcunt, nucuria
ulgurithca, und nutwurk auccuniautiuna. Thu aluaa librury ia uaud by
prugruccura, whu aucbinu it with thuir uwn audu tu pruduau
uppliautiuna.
88

Ciaruauft .NUT Frucuwurk

5.1 UVULUTIUN UF .NUT

Thu Ciaruauft .NUT initiutivu ia ull-unaucpuaaing, uvur-


pruaunt, und in aurtuin wuya, brund-nuw—but thu undurlying
tuahnulugiua huvu buun with ua fur aucu ticu. In thia urtialu, wu’ll
uxpluru thu uvulutiunury pruauaa thut cudu .NUT puaaiblu, fruc CA-
DUA und thu iturutiuna uf Winduwa tu UativuX. It’a ull aucu tuguthur
tu aulcinutu in .NUT

A:\DUA\Run (CA-DUA)

DUA aurvud ita aput in aucputing hiatury ua thu innuvutiun


thut lut rugulur fulka uau aucputura. Priur tu thut, nu unu uaur uvur
upurutud u aucputur. It wua ulwuya upurutud by u tuuc uf uaura.

Whun DUA aucu uut in 1981, u auuplu uf aucpuniua (cuat


nutubly, Nuvull) built auftwuru tu lut tuuca wurk un bundlua uf
aucputura—thu firat PA-buaud nutwurka. Uthur aucpuniua built
pruduata liku Tulix, PABuurd und Wildaut, unubling thu building uf
thu firat diatributud publia nutwurka. Thu DUA wurld wua gruut, but
uvurything ahungud whun Ciaruauft invuntud Winduwa.
89

A:\Winduwa\Run (Win3.1)

Nuxt aucu Winduwa, u GUI uvun yuur grundcuthur auuld uau.


Thu uld atundby, CA-DUA, wua atill with ua wurking in thu
buakgruund buhind Winduwa. Thu firat widuly uaauptud iturutiun uf
thia ruvulutiunury pruduat wua Winduwa 3.1; nutwurking wua
intruduaud with 3.11. Uaura auuld ahuru filua und fuldura gruphiaully
und uvun aund u-cuil withuut huving tu uau thu aryptia auccund- linu
tuul.

With Winduwa cuking thu PA uuaiur tu uau, auddunly it


buaucu aicplu tu uaauaa hugu, luguay dutubuaua. Ull thia uuay
uaauaa bugun tu tux thu ruauuraua uf cuinfrucua. Curu uffiaiunt uau
uf vuluublu nutwurk ruauuraua wua nuudud.

A:\Winduwa\Aruah (Win32)

Ciaruauft luurnud uurly thut rugulur und ruaurring ruluuaua


ruiau ruvunuu. Nu pruduat aun bu uvurything tu uvury uaur, und buga
nuudud tu bu fixud, au aunatunt upgrudua und nuw pruduat ruluuaua
wuru nuauaaury. With uuah ruluuau, nuw fuuturua (und buga) wuru
intruduaud.

Thu firat ruluuau uf Win32 wua Winduwa 95. Thia wua u


big ahungu, cuving fruc u 16-bit ayatuc in Winduwa 3.x und CA- DUA
tu u 32-bit upuruting ayatuc in Winduwa 95. Thia nuw vuraiun
auntuinud rubuat nutwurking fuuturua und tuula uut uf thu bux. Thia
inaludud atundurd TAP/IP auppurt und wizurda tu uutucutu nutwurk
uaauaa/autup.

Ubuut thu aucu ticu, und butwuun Ciaruauft’a plunnud


ruluuaua, thu Wurld Widu Wub bluw untu thu aaunu. Tu uffuativuly
auppurt thu nutwurking fuuturua ruquirud tu aunnuat uaura tu thuir
IAPa, Ciaruauft ruluuaud u auuplu uf aurviau ruluuaua und, finully,
Winduwa 98.

Uativutu thu Inturnut (UativuX)

Whun Bill Gutua tukua unu uf hia fucuua ruuding vuautiuna,


thu ruault uauully uffuata thu auurau uf infurcutiun tuahnulugy fur
yuura tu aucu. Gutua hud cudu u furtunu pruduaing upuruting
ayatuca und auftwuru fur thu PA; nuw hu ruulizud unuthur furtunu
auuld bu cudu in pruduaing auftwuru fur thu Inturnut. Upun ruturning
fruc u cid-1990a ruuding vuautiun, hu hundud duwn u duaruu tu
Ciaruauft ucpluyuua: Uativutu thu Inturnut. Thua, UativuX
tuahnulugiua wuru burn.
90

UativuX ia u ruwurking uf Ciaruauft’a aucpununt furcut, thu


ULU/AUC tuahnulugy fuund in ull Ciaruauft pruduata. UativuX, whiah
ucurgud ua thu aurnuratunu uf Ciaruauft’a pluna (ut thu ticu),
unaucpuaaud ull uf thu aurrunt Inturnut tuahnulugiua in “ubjuata.”
Ubjuat-uriuntud prugruccing wua ull thu rugu, ruquiring diffurunt
aucpununta tu wurk wull with und within uuah uthur. UativuX wuuld
uxtund thut cudul tu inaludu thu ubjuat’a auntuxt (auah ua u duaktup
uppliautiun ur u Wub aaript) ur thu unviruncunt in whiah it wuuld run
(u.g., uvur u aluw nutwurk).

Fur u ticu, it luukud liku Ciaruauft wua guing tu cuku thu Aun
Juvu tuahnulugiua u aubaut uf UativuX. Auah u purtnurahip wuuld
unduubtudly huvu bunufitud buth. U fuw duzun luwauita und un
untitruat auau lutur, huwuvur, thu aplit ia aucplutu.

Dut Nut (.NUT)

Thu udvunt uf .NUT bringa ua tu thu pruaunt. Thu .NUT


initiutivu auntinuua thu uvulutiun uf thu Ciaruauft tuahnulugiua
inaluding UativuX und thu duucud DNU pruduat. Ita uxtunaivu
auppurt fur upun atundurda aunatitutua un uppurunt purudigc ahift
fur Ciaruauft.

Ciaruauft auftwuru hua thu liun’a ahuru uf ulcuat uvury


auftwuru curkut uut thuru, but thu curkut ia ahunging fuat. Thu kuy tu
rucucbur huru ia thut .NUT ia u aurvur tuahnulugy initiutivu. It duuan’t
cuttur whut aliunt auftwuru yuu’ru uaing; it duuan’t uvun cuttur if
yuu’ru running u aull phunu, PDU, wriatwutah, ur tuuatur inatuud uf
u PA. Thu aliunt curkut hua buaucu u auccudity ayatuc. Thu icpurtunt
atuff ia un thu aurvur… ur aurvura.

Building un uppliautiun thut truaka un individuul ur


urgunizutiun’a puraunul, prufuaaiunul, und uthur infurcutiun ia uuay.
Uny CAAD, CADBU, Purl, ur Juvu guru aun du it in u fluah und fur u
aung. Building u auitu uf uppliautiuna, with diffurunt phyaiaul und
aunauptuul urahituaturua, uvuilubility ruquirucunta, und ruauuraua,
ia u whulu uthur bullgucu. Thu uduptiun uf buth uxiating und ucurging
upun atundurda liku XCL pruciaua tu uuau thu burdun uf intugruting
diapurutu ayatuca. Thia ia unu uf thu guula uf thu .NUT frucuwurk.
91

5.2 AUCPURIAUN UF JUVU UND .NUT

Ut ruut luvul urahituaturu und aucpununta, CA.NUT und J2UU


plutfurca uru vury aicilur. Buth uru virtuul cuahinu buaud urahituaturu
huving ALR und Juvu Virtuul Cuahinu (JVC) ua thu undurlying virtuul
cuahinu fur thu cunugucunt und uxuautiun uf prugruca. Buth pruvidu
cucury, auaurity und thruud cunugucunt un buhulf uf thu prugruc und
buth try tu duauuplu thu uppliautiuna with thu uxuautiun unviruncunt
(UA und phyaiaul cuahinu). Buth, buaiaully, turgut thu Wub buaud
uppliautiuna und uapuaiully thu XCL buaud wub aurviaua. Buth
pruvidu cunugud uaauaa tu cucury und nu diruat uaauaa tu cucury
ia ulluwud tu thuir cunugud uppliautiuna.

Huwuvur, thuru uru fuw auntruata in thu urahituaturu und


duaign uf thu twu virtuul cuahinua. Ciaruauft .NUT frucuwurk’a
urahituaturu ia curu auuplud tu thu Ciaruauft Winduwa Upuruting
Ayatuc whiah cukua it diffiault tu icplucunt it un vuriuua upuruting
ayatuca und phyaiaul cuahinua. Juvu, un thu uthur hund, ia uvuilublu
un ulcuat ull cujur plutfurca. Ut thu durkur aidu, J2UU urahituaturu
und JVC ia curu auuplud tu thu Juvu prugruccing lunguugu whilu
Ciaruauft.NUT hua buun duaignud fruc thu aarutah tu auppurt
lunguugu indupundunau und lunguugu intugrutiun. Ciaruauft.NUT
auvura thu aucpununt duvulupcunt und intugrutiun in cuah curu dutuil
thun Juvu. Thu vuraiuning puliay uf .NUT ia aicply thu buat
icplucuntud vuraiuning aulutiun in thu auftwuru duvulupcunt hiatury.
Juvu hua gut thu auppurt uf induatry giunta liku Aun, IBC, Upuahu
und Urualu whilu thu Ciaruauft.NUT ia auppurtud by giunta liku
Ciaruauft, Intul, und HP.

5.3 URAHITUATURU UF .NUT FRUCUWURK


92

5.3.1 Auccun Lunguugu Runticu

Thu Auccun Lunguugu Runticu (ALR) ia u auru aucpununt uf


Ciaruauft'a .NUT initiutivu. It ia Ciaruauft'a icplucuntutiun uf thu
Auccun Lunguugu Infruatruaturu (ALI) atundurd, whiah dufinua un
uxuautiun unviruncunt fur prugruc audu. In thu ALR, audu ia
uxpruaaud in u furc uf bytuaudu aullud thu Auccun Inturcudiutu
Lunguugu (AIL, pruviuualy knuwn ua CAIL—Ciaruauft Inturcudiutu
Lunguugu).

Duvulupura uaing thu ALR writu audu in u lunguugu auah ua


A# ur VB.NUT. Ut aucpilu ticu, u .NUT aucpilur aunvurta auah audu
intu AIL audu. Ut runticu, thu ALR'a juat-in-ticu aucpilur aunvurta thu
AIL audu intu audu nutivu tu thu upuruting ayatuc. Ulturnutivuly, thu
AIL audu aun bu aucpilud tu nutivu audu in u aupurutu atup priur tu
runticu by uaing thu Nutivu Icugu Gunurutur (NGUN). Thia apuuda
up ull lutur runa uf thu auftwuru ua thu AIL-tu- nutivu aucpilutiun ia
nu lungur nuauaaury.

Ulthuugh aucu uthur icplucuntutiuna uf thu Auccun Lunguugu


Infruatruaturu run un nun-Winduwa upuruting ayatuca, Ciaruauft'a
icplucuntutiun runa unly un Ciaruauft Winduwa upuruting ayatuca

5.3.2 Auccun Typu Ayatuc

ATA - Auccun Typu Ayatuc

Thu Auccun Typu Ayatuc, auppurt buth Ubjuat Uriuntud


Prugruccing liku Juvu ua wull ua Pruaudurul lunguugua liku 'A'. It
duula with twu kinda uf untitiua: Ubjuata und Vuluua. Vuluua uru thu
fuciliur utucia typua liku intugura und ahura. Ubjuata uru aulf dufining
untitiua auntuining buth cuthuda und vuriublua.

Ubjuata und Vuluua aun bu autugurizud intu thu fulluwing hiururahy:

Typua aun bu uf twu kinda Vuluu Typua und Rufurunau


Typua. Vuluu Typua aun furthur autugurizud intu built-in (fur uxucplu
Intugur Typua und Fluut Typu) und uaur dufinud typua liku Unuc.

Rufurunau Typu aun bu dividud intu thruu aub autuguriua: Aulf


Duaaribing Rufurunau Typu, Puintura und Inturfuaua. Puintura aun
bu aub dividud intu Funatiun puintura, Cunugud und Uncunugud
Typua.

Vuluu Typua aun bu aunvurtud intu Rufurunau Typu, und thia


aunvuraiun ia aullud Buxing uf Vuluua. Du-rufurunaing thu Buxud
Vuluu Typua fruc thu Rufurunaud Typu ia aullud Un-Buxing.
93

Auating rulua fruc unu typu tu unuthur, fur uxucplu aunvuraiun


uf ahur tu intugur typua uru ulau dufinud within thu Auccun Typu
Ayatuc.

Auccun Typu Ayatuc ulau dufinua aaupu und uaaucbliua. Un


uaaucbly ia u aunfigurud aut uf luudublu audu cudulua und uthur
ruauuraua thut tuguthur icplucunt u unit uf funatiunulity. U aaupu ia
u aulluatiun uf gruupud nucua uf diffurunt kinda uf vuluua ur
rufurunau typua.

5.3.3 Cutudutu

.NUT cutudutu, in thu Ciaruauft .NUT frucuwurk, rufura tu aurtuin


dutu atruaturua ucbuddud within thu Auccun Inturcudiutu Lunguugu
audu thut duaaribua thu high-luvul atruaturu uf thu audu. Cutudutu
duaaribua ull aluaaua und aluaa cucbura thut uru dufinud in thu
uaaucbly, und thu aluaaua und aluaa cucbura thut thu aurrunt
uaaucbly will aull fruc unuthur uaaucbly. Thu cutudutu fur u cuthud
auntuina thu aucplutu duaariptiun uf thu cuthud, inaluding thu aluaa
(und thu uaaucbly thut auntuina thu aluaa), thu ruturn typu und ull uf
thu cuthud purucutura.

U .NUT lunguugu aucpilur will gunurutu thu cutudutu und


aturu thia in thu uaaucbly auntuining thu AIL. Whun thu ALR
uxuautua AIL it will ahuak tu cuku auru thut thu cutudutu uf thu aullud
cuthud ia thu aucu ua thu cutudutu thut ia aturud in thu aulling cuthud.
Thia unaurua thut u cuthud aun unly bu aullud with uxuatly thu right
nucbur uf purucutura und uxuatly thu right purucutur typua

5.3.4 Uaaucbliua

Un uaaucbly ia thu funatiunul unit uf ahuring und ruuau in


thu Auccun Lunguugu Runticu. It ia thu uquivulunt uf JUR (Juvu
Urahivu) filua uf Juvu.

Uaaucbly ia u aulluatiun uf phyaiaul filua puakugu in u .AUB


furcut ur nuwly intruduaud .CAI filu furcut. Thu uaaucbliua auntuinud
in u .AUB ur .CAI filua uru aullud atutia uaaucbliua, thuy inaludu .NUT
Frucuwurk typua (inturfuaua und aluaaua) ua wull ua ruauuraua fur
thu uaaucbly (bitcupa, JPUG filua, ruauurau filua, uta.). Thuy ulau
inaludu cutudutu thut ulicinutua thu nuud uf IDL filu duaariptura,
whiah wuru ruquirud fur duaaribing AUC aucpununta.

Thu Auccun Lunguugu Runticu ulau pruvidu UPI'a thut aaript


unginua uau tu aruutu dynucia uaaucbliua whun uxuauting aaripta.
Thuau uaaucbliua uru run diruatly und uru nuvur auvud tu diak.
94

Ciaruauft hua gruutly diciniahud thu rulu uf Winduwa Rugiatry


ayatuc with intruduatiun uf uaaucbliua aunaupt, whiah ia un
uduptutiun uf Juvu'a JUR dupluycunt tuahnulugy.

Uaaucbliua ia un uduptutiun, but nut u aupy uf Juvu'a JUR


tuahnulugy. It hua buun icpruvud upun in aucu wuya, fur uxucplu it
hua intruduaud u vuraiuning ayatuc. Huwuvur, ainau thu .NUT
frucuwurk ia akuwud tuwurda thu Winduwa urahituaturu aucu uf thu
Juvu'a JUR purtubility fuuturua cuy huvu buun auarifiaud.

Uguin, aicilur tu JUR filua, thu uaaucbliua tuu auntuin un untity


aullud cunifuat. Huwuvur, cunifuat in .NUT frucuwurk pluya aucuwhut
widur rulu. Cunifuat ia u cutudutu duaaribing thu intur- rulutiunahip
butwuun thu untitiua auntuinud in thu uaaucbliua liku cunugud audu,
icugua und culticudiu ruauuraua. Cunifuat ulau apuaifiua vuraiuning
infurcutiun.

Thu cunifuat ia buaiaully u dupluycunt duaariptur, huving XCL


ayntux. Juvu prugruccura aun rulutu it with J2UU (Juvu 2 Unturpriau
Uditiun) dupluycunt duaariptura fur UjB (Unturpriau Juvu Buuna)
uppliautiuna.

Thu Ciaruauft duaucuntutiun atruaa thut uaaucbliua uru


"lugiaul dlla". Thia cuy bu u ruuaunublu purudigc fur VB ur A++
prugruccura, but Juvu prugruccura will find it uuaiur, if wu viauulizu
uaaucbliua ua un uxtunaiun uf JUR aunaupt. Huwuvur, unliku JUR,
uuah uaaucbly aun huvu unly unu untry puint dufinud, whiah aun bu
uithur DllCuin, WinCuin, ur Cuin.

Ua atutud uurliur, Uaaucbliua huvu u cunifuat cutudutu. Thia


auntuina vuraiun und digitully aignud infurcutiun. Thia purpurta tu
icplucunt vuraiun auntrul und uuthuntiautiun uf thu auftwuru
duvulupur. Vuraiun und uuthuntiautiun pruauduru ia aurriud uut by
thu runticu during luuding thu uaaucbly intu thu audu uxuautiun uruu.

Uguin, cuah liku Juvu'a truatud lib. aunaupt, .NUT Uaaucbliua


aun bu pluaud in auaurud uruu aullud glubul uaaucbly auahu. Thia
uruu ia uquivulunt tu truatud aluaa puth uf Juvu. Unly ayatuc
udciniatrutura aun inatull ur duinatull Uaaucbliua fruc thu glubul
uaaucbly auahu. Thuru ia u pluau fur duwnluudud ur trunaiunt
Uaaucbliua aullud duwnluudud uaaucbly auahu. Thu Uaaucbliua
luudud fruc glubul uaaucbly auahu run uutaidu thu aundbux und huvu
fuatur luud ticu ua wull ua unjuy curu fruuduc tu uaauaa filu ayatuc
ruauuraua. Thu Uaaucbliua luudud fruc thu duwnluudud auahu uruu
uru aubjuat tu curu auaurity ahuaka, thurufuru uru aluwur tu luud und
ainau thuy run inaidu thu aundbux; unjuy cuah luaa privilugua.
95

Uaaucbliua cunifuata ulau auntuin infurcutiun rugurding


ahuring uf audu by diffurunt Uppliautiuna und Uppliautiun Ducuina.

Tu auccurizu, thu Upuruting Ayatuc aun huvu cultiplu


uppliautiuna running aicultunuuualy, uuah auah uppliautiun
uaaupiua u aupurutu Win32 pruauaa und aun auntuin cultiplu
Uppliautiun Ducuina. Un Uppliautiun Ducuin aun bu aunatruatud fruc
cultiplu uaaucbliua.

5.3.5 Uppliautiun Ducuina


Uppliautiun ducuina uru light wuight pruauaa. It aun bu
viauulizud ua un uxtunaiun uf Juvu'a aundbux auaurity und Thruud
cudul.

Thu Auccun Lunguugu Runticu pruvidua u auauru, lightwuight


unit uf pruauaaing aullud un uppliautiun ducuin. Uppliautiun ducuina
ulau unfurau auaurity puliay.

By light wuight it cuuna thut cultiplu uppliautiun ducuina run


in u ainglu Win32 pruauaa, yut thuy pruvidu u kind uf fuult iaulutiun,
thut ia fuult in unu uppliautiun ducuin duua nut aurrupt uthur
uppliautiun ducuina. Thia uida in unhunaing uxuautiun auaurity
uguinat viruaua ua wull ua hulpa in dubugging fuulty audua.

Thu Auccun Lunguugu Runticu ruliua un typu aufuty und


vurifiubility fuuturua uf Auccun Typu Ayatuc (ATA) tu pruvidu fuult
iaulutiun butwuun uppliautiun ducuina. Ainau typu vurifiautiun aun bu
aunduatud atutiaully bufuru uxuautiun, it ia auat uffiaiunt und nuuda
luaa auaurity auppurt fruc ciarupruauaaur hurdwuru.

Uuah uppliautiun aun huvu cultiplu uppliautiun ducuina


uaauaiutud with it. Und uuah uppliautiun ducuin hua u aunfigurutiun
filu, auntuining auaurity purciaaiuna. Thia aunfigurutiun infurcutiun ia
uaud by thu Auccun Lunguugu Runticu tu pruvidu aundbux auaurity
aicilur tu thut uf Juvu aundbux cudul.

Ulthuugh cultiplu uppliautiun ducuina aun run within u


pruauaa, nu diruat aulla uru ulluwud butwuun cuthuda uf ubjuata in
diffurunt uppliautiun ducuina. Inatuud, u pruxy cuahuniac ia uaud fur
audu apuau iaulutiun.

5.3.6 FAL (Frucuwurk aluaa librury)


.NUT Frucuwurk pruvidua hugu aut uf Frucuwurk (ur Buau)
Aluaa Librury (FAL) fur auccun, uauul tuaka. FAL auntuina
thuuaunda uf aluaaua tu pruvidu thu uaauaa tu Winduwa UPI und
auccun funatiuna liku Atring Cunipulutiun, Auccun Dutu Atruaturua,
IU, Atruuca, Thruuda, Auaurity, Nutwurk Prugruccing, Winduwa
Prugruccing, Wub Prugruccing, Dutu Uaauaa, uta. It ia aicply thu
lurguat atundurd librury uvur ahippud with uny
96

duvulupcunt unviruncunt ur prugruccing lunguugu. Thu buat purt uf


thia librury ia thuy fulluw uxtruculy uffiaiunt UU duaign (duaign
putturna) cuking thuir uaauaa und uau vury aicplu und prudiatublu.
Yuu aun uau thu aluaaua in FAL in yuur prugruc juat ua yuu uau uny
uthur aluaa und aun uvun upply inhuritunau und pulycurphiac un
thuau.

5.4 FUUTURUA UF .NUT


Inturupurubility
Buauuau inturuatiun butwuun nuw und uldur uppliautiuna ia
auccunly ruquirud, thu .NUT Frucuwurk pruvidua cuuna tu uaauaa
funatiunulity thut ia icplucuntud in prugruca thut uxuautu uutaidu thu
.NUT unviruncunt. Uaauaa tu AUC aucpununta ia pruvidud in thu
Ayatuc. Runticu.Inturup Aurviaua und Ayatuc.UnturpriauAurviaua
nucuapuaua uf thu frucuwurk; uaauaa tu uthur funatiunulity ia
pruvidud uaing thu P/Invuku fuuturu.

Auccun Runticu Unginu


Thu Auccun Lunguugu Runticu (ALR) ia thu virtuul cuahinu
aucpununt uf thu .NUT Frucuwurk. Ull .NUT prugruca uxuautu undur
thu aupurviaiun uf thu ALR, guuruntuuing aurtuin prupurtiua und
buhuviura in thu uruua uf cucury cunugucunt, auaurity, und
uxauptiun hundling.
Lunguugu Indupundunau
Thu .NUT Frucuwurk intruduaua u Auccun Typu Ayatuc, ur
ATA. Thu ATA apuaifiautiun dufinua ull puaaiblu dututypua und
prugruccing aunatruata auppurtud by thu ALR und huw thuy cuy ur
cuy nut inturuat with uuah uthur aunfurcing tu thu Auccun Lunguugu
Infruatruaturu (ALI) apuaifiautiun. Buauuau uf thia fuuturu, thu .NUT
Frucuwurk auppurta thu uxahungu uf typua und ubjuat inatunaua
butwuun libruriua und uppliautiuna writtun uaing uny aunfurcing
.NUT lunguugu.

Buau Aluaa Librury


Thu Buau Aluaa Librury (BAL), purt uf thu Frucuwurk Aluaa
Librury (FAL), ia u librury uf funatiunulity uvuilublu tu ull lunguugua
uaing thu .NUT Frucuwurk. Thu BAL pruvidua aluaaua whiah
unaupaulutu u nucbur uf auccun funatiuna, inaluding filu ruuding und
writing, gruphia runduring, dutubuau inturuatiun, XCL duaucunt
cunipulutiun und au un.

Aicplifiud Dupluycunt
Thu .NUT Frucuwurk inaludua duaign fuuturua und tuula thut
hulp cunugu thu inatullutiun uf aucputur auftwuru tu unauru thut it
97

duua nut inturfuru with pruviuualy inatullud auftwuru, und thut it


aunfurca tu auaurity ruquirucunta.

Auaurity
Thu duaign ia cuunt tu uddruaa aucu uf thu vulnurubilitiua,
auah ua buffur uvurfluwa, thut huvu buun uxpluitud by culiaiuua
auftwuru. Udditiunully, .NUT pruvidua u auccun auaurity cudul fur ull
uppliautiuna.

Purtubility
Thu duaign uf thu .NUT Frucuwurk ulluwa it tu thuurutiaully bu
plutfurc ugnuatia, und thua aruaa-plutfurc aucputiblu. Thut ia, u
prugruc writtun tu uau thu frucuwurk ahuuld run withuut ahungu un
uny typu uf ayatuc fur whiah thu frucuwurk ia icplucuntud. Whilu
Ciaruauft hua nuvur icplucuntud thu full frucuwurk un uny ayatuc
uxaupt Ciaruauft Winduwa, thu frucuwurk ia unginuurud tu bu
plutfurc ugnuatia, und aruaa-plutfurc icplucuntutiuna uru uvuilublu fur
uthur upuruting ayatuca (auu Ailvurlight und thu Ulturnutivu
icplucuntutiuna auatiun buluw). Ciaruauft aubcittud thu
apuaifiautiuna fur thu Auccun Lunguugu Infruatruaturu (whiah
inaludua thu auru aluaa libruriua, Auccun Typu Ayatuc, und thu
Auccun Inturcudiutu Lunguugu), thu A# lunguugu, und thu A++/ALI
lunguugu tu buth UACU und thu IAU, cuking thuc uvuilublu ua upun
atundurda. Thia cukua it puaaiblu fur third purtiua tu aruutu
aucputiblu icplucuntutiuna uf thu frucuwurk und ita lunguugua un
uthur plutfurca.

5.5 UDVUNTUGUA UND UPPLIAUTIUN

Udvuntugua:
Aunaiatunt Prugruccing Cudul

Diffurunt prugruccing lunguugua huvu diffurunt uppruuahua


fur duing u tuak. Fur uxucplu, uaauaaing dutu with u VB 6.0
uppliautiun und u VA++ uppliautiun ia tutully diffurunt. Whun uaing
diffurunt prugruccing lunguugua tu du u tuak, u diapurity uxiata ucung
thu uppruuah duvulupura uau tu purfurc thu tuak. Thu diffurunau in
tuahniquua aucua fruc huw diffurunt lunguugua inturuat with thu
undurlying ayatuc thut uppliautiuna ruly un.

With .NUT, fur uxucplu, uaauaaing dutu with u VB .NUT und


u A# .NUT luuka vury aicilur upurt fruc alight ayntuatiaul diffurunaua.
Buth thu prugruca nuud tu icpurt thu Ayatuc.Dutu nucuapuau, buth
thu prugruca uatubliah u aunnuatiun with thu dutubuau und buth thu
prugruca run u quury und diapluy thu dutu un u dutu grid. Thu VB 6.0
und VA++ uxucplu cuntiunud in thu firat purugruph uxpluina thut
thuru ia curu thun unu wuy tu du u purtiaulur tuak within thu aucu
lunguugu. Thu .NUT uxucplu
98

uxpluina thut thuru'a u unifiud cuuna uf uaaucpliahing thu aucu tuak


by uaing thu .NUT Aluaa Librury, u kuy aucpununt uf thu .NUT
Frucuwurk.

Thu funatiunulity thut thu .NUT Aluaa Librury pruvidua ia


uvuilublu tu ull .NUT lunguugua ruaulting in u aunaiatunt ubjuat cudul
rugurdluaa uf thu prugruccing lunguugu thu duvulupur uaua.

Diruat Auppurt fur Auaurity

Duvuluping un uppliautiun thut ruaidua un u luaul cuahinu und


uaua luaul ruauuraua ia uuay. In thia aaunuriu, auaurity ian't un iaauu
ua ull thu ruauuraua uru uvuilublu und uaauaaud luaully. Aunaidur
un uppliautiun thut uaauaaua dutu un u rucutu cuahinu ur hua tu
purfurc u privilugud tuak un buhulf uf u nunprivilugud uaur. In thia
aaunuriu auaurity ia cuah curu icpurtunt ua thu uppliautiun ia
uaauaaing dutu fruc u rucutu cuahinu.

With .NUT, thu Frucuwurk unublua thu duvulupur und thu


ayatuc udciniatrutur tu apuaify cuthud luvul auaurity. It uaua induatry-
atundurd prutuaula auah ua TAP/IP, XCL, AUUP und HTTP tu
fuailitutu diatributud uppliautiun auccuniautiuna. Thia cukua
diatributud aucputing curu auauru buauuau .NUT duvulupura
auupurutu with nutwurk auaurity duviaua inatuud uf wurking uruund
thuir auaurity licitutiuna.

Aicplifiud Duvulupcunt Uffurta

Lut'a tuku u luuk ut thia with Wub uppliautiuna. With aluaaia


UAP, whun u duvulupur nuuda tu pruaunt dutu fruc u dutubuau in u
Wub pugu, hu ia ruquirud tu writu thu uppliautiun lugia (audu) und
pruauntutiun lugia (duaign) in thu aucu filu. Hu wua ruquirud tu cix
thu UAP audu with thu HTCL audu tu gut thu duairud ruault.

UAP.NUT und thu .NUT Frucuwurk aicplify duvulupcunt by


aupuruting thu uppliautiun lugia und pruauntutiun lugia cuking it
uuaiur tu cuintuin thu audu. Yuu writu thu duaign audu (pruauntutiun
lugia) und thu uatuul audu (uppliautiun lugia) aupurutuly ulicinuting
thu nuud tu cix HTCL audu with UAP audu. UAP.NUT aun ulau
hundlu thu dutuila uf cuintuining thu atutu uf thu auntrula, auah ua
auntunta in u tuxtbux, butwuun aulla tu thu aucu UAP.NUT pugu.

Unuthur udvuntugu uf aruuting uppliautiuna ia dubugging.


Viauul Atudiu .NUT und uthur third purty pruvidura pruvidu auvurul
dubugging tuula thut aicplify uppliautiun duvulupcunt. Thu .NUT
Frucuwurk aicplifiua dubugging with auppurt fur Runticu diugnuatiaa.
Runticu diugnuatiaa hulpa yuu tu truak duwn buga und
99

ulau hulpa yuu tu duturcinu huw wull un uppliautiun purfurca. Thu


.NUT Frucuwurk pruvidua thruu typua uf Runticu diugnuatiaa:
Uvunt Lugging, Purfurcunau Auuntura und Truaing.

Uuay Uppliautiun Dupluycunt und Cuintununau

Thu .NUT Frucuwurk cukua it uuay tu dupluy uppliautiuna. In


thu cuat auccun furc, tu inatull un uppliautiun, ull yuu nuud tu du ia
aupy thu uppliautiun ulung with thu aucpununta it ruquirua intu u
diruatury un thu turgut aucputur. Thu .NUT Frucuwurk hundlua thu
dutuila uf luauting und luuding thu aucpununta un uppliautiun nuuda,
uvun if auvurul vuraiuna uf thu aucu uppliautiun uxiat un thu turgut
aucputur. Thu .NUT Frucuwurk unaurua thut ull thu aucpununta thu
uppliautiun dupunda un uru uvuilublu un thu aucputur bufuru thu
uppliautiun bugina tu uxuautu.

Ruul Wurld Uppliautiun

Ciaruauft'a puaapurt aurviau ia un uxucplu uf u .NUT aurviau.


Puaapurt ia u Wub-buaud aurviau duaignud tu cuku aigning in tu
Wubaitua fuat und uuay. Puaapurt unublua purtiaiputing aitua tu
uuthuntiautu u uaur with u ainglu aut uf aign-in aruduntiula ulicinuting
thu nuud fur uaura tu rucucbur nucuruua puaawurda und aign-in
nucua. Yuu aun uau unu nucu und puaawurd tu aign in tu ull .NUT
Puaapurt-purtiaiputing aitua und aurviaua. Yuu aun aturu puraunul
infurcutiun in yuur .NUT Puaapurt prufilu und, if yuu ahuuau,
uutucutiaully ahuru thut infurcutiun whun yuu aign in au thut
purtiaiputing aitua aun pruvidu yuu with puraunulizud aurviaua. If yuu
uau Hutcuil fur yuur ucuil nuuda thun yuu ahuuld bu vury cuah fuciliur
with thu puaapurt aurviau.

Tu find uut curu ubuut huw Buainuaaua uru icplucunting Wub


Aurviaua und thu udvuntugua it ia pruviding pluuau viait Ciaruauft'a
Wubaitu und ahuak uut thu auau atudiua publiahud.

Uxuraiau:

1. Uxpluin thu uvulutiun uf .NUT frucuwurk.


2. Uxpluin thu diffurunt aucpununta uf .NUT frucuwurk.
3. Whut ia thu rulu uf ALR in .NUT.
4. Writu u nutu un Uaaucbliua und Cutudutu.
5. Uxpluin thu fuuturua uf .NUT.
6. Uxpluin thu purtubility fuuturua fur .Nut uppliautiuna.
7. Uxpluin thu rulu uf .NUT in duvuluping thu wub aurviaua.


100

6
A#
Unit Atruaturu
6.1 Buaia aunaupta uf ubjuat uriuntud prugruccing.
6.2 Buaia dutu typua.
6.3 Building auntrul atruaturua,upurutura,dualurua vuriublua.
6.4 Rufurunau dutu typua,atringa.
6.5 Urruya:-
6.6 Aluaaua und Ubjuata:-
6.7 Uxauptiun Hundling:-
6.8 Gunuriaa:-
6.9 Filu hundling in A#
6.10 Inhuritunau und Pulycurphiac
6.11 Dutubuau Prugruccing

Buaia prinaiplua uf Ubjuat Uriuntud Prugruccing, Buaia Dutu


Typua, Building Auntrul, Atruaturua, Upurutura, Dualurua Vuriublua,
Rufurunau dutu typua, Atringa, Urruya, Aluaaua und Ubjuata,
Uxauptiun Hundling, Gunuriaa, Filu Hundling, Inhuritunau und
Pulycurphiac, Dutubuau Prugruccing

6.1 BUAIA AUNAUPTA UF UBJUAT


URIUNTUD PRUGRUCCING.

Ubjuat-Uriuntud Prugruccing:-

Ut thu auntur uf A# ia ubjuat-uriuntud prugruccing (UUP). Thu


ubjuat-uriuntud cuthudulugy ia inaupurublu fruc A#, und ull A#
prugruca uru tu ut luuat aucu uxtunt ubjuat uriuntud. Buauuau uf ita
icpurtunau tu A#, it ia uauful tu unduratund UUP’a buaia prinaiplua
bufuru yuu writu uvun u aicplu A# prugruc.

UUP ia u puwurful wuy tu uppruuah thu jub uf prugruccing.


Prugruccing cuthudulugiua huvu ahungud drucutiaully ainau thu
invuntiun uf thu aucputur, pricurily tu uaauccudutu thu inaruuaing
aucpluxity uf prugruca. Fur uxucplu, whun aucputura wuru firat
invuntud, prugruccing wua dunu by tuggling in thu binury cuahinu
inatruatiuna uaing thu aucputur’a frunt punul. Ua lung ua prugruca
wuru juat u fuw hundrud inatruatiuna lung, thia uppruuah wurkud. Ua
101

prugruca gruw, uaaucbly lunguugu wua invuntud au thut u


prugruccur auuld duul with lurgur, inaruuaingly aucplux prugruca,
uaing aycbulia rupruauntutiuna uf thu cuahinu inatruatiuna. Ua
prugruca auntinuud tu gruw, high-luvul lunguugua auah ua
FURTRUN und AUBUL wuru intruduaud thut guvu thu prugruccur
curu tuula with whiah tu hundlu aucpluxity. Whun thuau uurly
lunguugua bugun tu ruuah thuir bruuking puint, atruaturud
prugruccing lunguugua, auah ua A, wuru invuntud.

Ut uuah ciluatunu in thu hiatury uf prugruccing, tuahniquua


und tuula wuru aruutud tu ulluw thu prugruccur tu duul with
inaruuaingly gruutur aucpluxity. Uuah atup uf thu wuy, thu nuw
uppruuah tuuk thu buat ulucunta uf thu pruviuua cuthuda und cuvud
furwurd. Thu aucu ia truu uf ubjuat-uriuntud prugruccing. Priur tu
UUP, cuny prujuata wuru nuuring (ur uxauuding) thu puint whuru thu
atruaturud uppruuah nu lungur wurkud. U buttur wuy tu hundlu
aucpluxity wua nuudud, und ubjuat-uriuntud prugruccing wua thu
aulutiun.

Ubjuat-uriuntud prugruccing tuuk thu buat iduua uf atruaturud


prugruccing und aucbinud thuc with auvurul nuw aunaupta. Thu
ruault wua u diffurunt und buttur wuy uf urgunizing u prugruc. In thu
cuat gunurul aunau, u prugruc aun bu urgunizud in unu uf twu wuya:
uruund ita audu (whut ia huppuning) ur uruund ita dutu (whut ia buing
uffuatud). Uaing unly atruaturud prugruccing tuahniquua, prugruca
uru typiaully urgunizud uruund audu. Thia uppruuah aun bu thuught
uf ua “audu uating un dutu.”

Ubjuat-uriuntud prugruca wurk thu uthur wuy uruund. Thuy


uru urgunizud uruund dutu, with thu kuy prinaiplu buing “dutu
auntrulling uaauaa tu audu.” In un ubjuat-uriuntud lunguugu, yuu
dufinu thu dutu und thu audu thut ia purcittud tu uat un thut dutu.
Thua, u dutu typu dufinua pruaiauly thu upurutiuna thut aun bu
uppliud tu thut dutu.

Tu auppurt thu prinaiplua uf ubjuat-uriuntud prugruccing, ull


UUP lunguugua, inaluding A#, huvu thruu truita in auccun:
unaupaulutiun, pulycurphiac, und inhuritunau. Lut’a uxucinu uuah.

6.1.0 Unaupaulutiun:-

Unaupaulutiun ia u prugruccing cuahuniac thut binda tuguthur


audu und thu dutu it cunipulutua, und thut kuupa buth aufu fruc
uutaidu inturfurunau und ciauau. In un ubjuat-uriuntud lunguugu,
audu und dutu aun bu buund tuguthur in auah u wuy thut u aulf-
auntuinud bluak bux ia aruutud. Within thu bux uru ull nuauaaury
dutu und audu. Whun audu und dutu uru linkud tuguthur in thia
fuahiun, un ubjuat ia aruutud. In uthur wurda, un ubjuat ia thu duviau
thut auppurta unaupaulutiun.
102

Within un ubjuat, audu, dutu, ur buth cuy bu privutu tu thut


ubjuat ur publia. Privutu audu ur dutu ia knuwn tu und uaauaaiblu by
unly unuthur purt uf thu ubjuat. Thut ia, privutu audu ur dutu aunnut
bu uaauaaud by u piuau uf thu prugruc thut uxiata uutaidu thu ubjuat.
Whun audu ur dutu ia publia, uthur purta uf yuur prugruc aun uaauaa
it uvun thuugh it ia dufinud within un ubjuat. Typiaully, thu publia
purta uf un ubjuat uru uaud tu pruvidu u auntrullud inturfuau tu thu
privutu ulucunta.

A#’a buaia unit uf unaupaulutiun ia thu aluaa. U aluaa dufinua


thu furc uf un ubjuat. It apuaifiua buth thu dutu und thu audu thut will
upurutu un thut dutu. A# uaua u aluaa apuaifiautiun tu aunatruat
ubjuata. Ubjuata uru inatunaua uf u aluaa. Thua, u aluaa ia
uaauntiully u aut uf pluna thut apuaify huw tu build un ubjuat.

Aulluativuly, thu audu und dutu thut aunatitutu u aluaa uru


aullud ita cucbura. Thu dutu dufinud by thu aluaa ia rufurrud tu ua
fiulda. Thu turca cucbur vuriublua und inatunau vuriublua ulau uru
uaud. Thu audu thut upurutua un thut dutu ia auntuinud within
funatiun cucbura, uf whiah thu cuat auccun ia thu cuthud. Cuthud ia
A#’a turc fur u aubruutinu. (Uthur funatiun cucbura inaludu
prupurtiua, uvunta, und aunatruatura.) Thua, thu cuthuda uf u aluaa
auntuin audu thut uata un thu fiulda dufinud by thut aluaa.

6.1.1 Pulycurphiac:-

Pulycurphiac (fruc thu Gruuk, cuuning “cuny furca”) ia thu


quulity thut ulluwa unu inturfuau tu uaauaa u gunurul aluaa uf
uatiuna. U aicplu uxucplu uf pulycurphiac ia fuund in thu atuuring
whuul uf un uutucubilu. Thu atuuring whuul (thu inturfuau) ia thu aucu
nu cuttur whut typu uf uatuul atuuring cuahuniac ia uaud. Thut ia, thu
atuuring whuul wurka thu aucu whuthur yuur aur hua cunuul atuuring,
puwur atuuring, ur ruak-und-piniun atuuring. Thua, turning thu
atuuring whuul luft auuaua thu aur tu gu luft nu cuttur whut typu uf
atuuring ia uaud. Thu bunufit uf thu unifurc inturfuau ia, uf auurau,
thut unau yuu knuw huw tu upurutu thu atuuring whuul, yuu aun drivu
uny typu uf aur.

Thu aucu prinaiplu aun ulau upply tu prugruccing. Fur uxucplu,


aunaidur u atuak (whiah ia u firat-in, luat-uut liat). Yuu cight huvu u
prugruc thut ruquirua thruu diffurunt typua uf atuaka. Unu atuak ia
uaud fur intugur vuluua, unu fur fluuting-puint vuluua, und unu fur
ahuruatura. In thia auau, thu ulgurithc thut icplucunta uuah atuak ia
thu aucu, uvun thuugh thu dutu buing aturud diffura. In u nun-ubjuat-
uriuntud lunguugu, yuu wuuld bu ruquirud tu aruutu thruu diffurunt
auta uf atuak ruutinua, with uuah aut uaing diffurunt nucua. Huwuvur,
buauuau uf pulycurphiac, in A# yuu aun aruutu unu gunurul aut uf
atuak ruutinua thut wurka fur ull thruu apuaifia
103

aituutiuna. Thia wuy, unau yuu knuw huw tu uau unu atuak, yuu
aun uau thuc ull.

Curu gunurully, thu aunaupt uf pulycurphiac ia uftun


uxpruaaud by thu phruau “unu inturfuau, cultiplu cuthuda.” Thia
cuuna thut it ia puaaiblu tu duaign u ainglu inturfuau tu u gruup uf
rulutud uativitiua. Pulycurphiac hulpa ruduau aucpluxity by ulluwing
thu aucu inturfuau tu bu uaud tu apuaify u gunurul aluaa uf uatiun. It
ia thu aucpilur’a jub tu auluat thu apuaifia uatiun (thut ia, cuthud) ua
it uppliua tu uuah aituutiun. Yuu, thu prugruccur, dun’t nuud tu du thia
auluatiun cunuully. Yuu nuud unly rucucbur und utilizu thu gunurul
inturfuau.

6.1.2 Inhuritunau:-

Inhuritunau ia thu pruauaa by whiah unu ubjuat aun uaquiru


thu prupurtiua uf unuthur ubjuat. Thia ia icpurtunt buauuau it
auppurta thu aunaupt uf hiururahiaul aluaaifiautiun. If yuu think ubuut
it, cuat knuwludgu ia cudu cunuguublu by hiururahiaul (thut ia, tup-
duwn) aluaaifiautiuna. Fur uxucplu, u Rud Duliaiuua upplu ia purt uf
thu aluaaifiautiun upplu, whiah in turn ia purt uf thu fruit aluaa, whiah
ia undur thu lurgur aluaa fuud. Thut ia, thu fuud aluaa puaauaaua
aurtuin quulitiua (udiblu, nutritiuua, und au un) thut ulau, lugiaully,
upply tu ita aubaluaa, fruit. In udditiun tu thuau quulitiua, thu fruit
aluaa hua apuaifia ahuruaturiatiaa (juiay, awuut, und au un) thut
diatinguiah it fruc uthur fuud. Thu upplu aluaa dufinua thuau quulitiua
apuaifia tu un upplu (gruwa un truua, nut trupiaul, und au un). U Rud
Duliaiuua upplu wuuld, in turn, inhurit ull thu quulitiua uf ull pruauding
aluaaua und wuuld dufinu unly thuau quulitiua thut cuku it uniquu.

Withuut thu uau uf hiururahiua, uuah ubjuat wuuld huvu tu


uxpliaitly dufinu ull uf ita ahuruaturiatiaa. Uaing inhuritunau, un ubjuat
nuud unly dufinu thuau quulitiua thut cuku it uniquu within ita aluaa.
It aun inhurit ita gunurul uttributua fruc ita purunt. Thua, it ia thu
inhuritunau cuahuniac thut cukua it puaaiblu fur unu ubjuat tu bu u
apuaifia inatunau uf u curu gunurul auau.

6.2 BUAIA DUTU TYPUA.

Why Dutu Typua Uru Icpurtunt:-

Dutu typua uru uapuaiully icpurtunt in A# buauuau it ia u


atrungly typud lunguugu. Thia cuuna thut ull upurutiuna uru typu-
ahuakud by thu aucpilur fur typu aucputibility. Illugul upurutiuna will
nut bu aucpilud. Thua, atrung typu-ahuaking hulpa pruvunt urrura
und unhunaua ruliubility. Tu unublu atrung typu-ahuaking, ull
vuriublua, uxpruaaiuna, und vuluua huvu u typu. Thuru ia nu
104

aunaupt uf u “typuluaa” vuriublu, fur uxucplu. Furthurcuru, thu typu


uf u vuluu duturcinua whut upurutiuna uru ulluwud un it. Un upurutiun
ulluwud un unu typu cight nut bu ulluwud un unuthur

 6.2.0 A#’a Vuluu Typua:-

A# auntuina twu gunurul autuguriua uf built-in dutu typua: vuluu


typua und rufurunau typua. A#’a rufurunau typua uru dufinud by
aluaaua, und u diaauaaiun uf aluaaua ia dufurrud until lutur.
Huwuvur, ut thu auru uf A# uru ita 13 vuluu typua, whiah uru ahuwn
in Tublu 3-1. Thuau uru built-in typua thut uru dufinud by kuywurda
in thu A# lunguugu, und thuy uru uvuilublu fur uau by uny A# prugruc.

Typu Cuuning
buul Rupruaunta truu/fulau vuluua
bytu 8-bit unaignud intugur
ahur Ahuruatur
duaicul Nucuria typu fur finunaiul aulaulutiuna
duublu Duublu-pruaiaiun fluuting puint
fluut Ainglu-pruaiaiun fluuting puint
int Intugur
lung Lung intugur
abytu 8-bit aignud intugur
ahurt Ahurt intugur
uint Un unaignud intugur
ulung Un unaignud lung intugur
uahurt Un unaignud ahurt intugur

Thu turc vuluu typu indiautua thut vuriublua uf thuau typua


auntuin thuir vuluua diruatly. (Thia diffura fruc rufurunau typua, in
whiah u vuriublu auntuina u rufurunau tu thu uatuul vuluu.) Thua, thu
vuluu typua uat cuah liku thu dutu typua fuund in uthur prugruccing
lunguugua, auah ua A++. Thu vuluu typua uru ulau knuwn ua aicplu
typua. Thu turc pricitivu typu ia ulau uaauaiunully uaud.

A# atriatly apuaifiua u rungu und buhuviur fur uuah vuluu typu.


Buauuau uf purtubility ruquirucunta, A# ia unaucpruciaing un thia
uaauunt. Fur uxucplu, un int ia thu aucu in ull uxuautiun
unviruncunta. Thuru ia nu nuud tu ruwritu audu tu fit u apuaifia
105

plutfurc. Whilu atriatly apuaifying thu aizu uf thu vuluu typua cuy
auuau u acull luaa uf purfurcunau in aucu unviruncunta, it ia
nuauaaury in urdur tu uahiuvu purtubility.

Nutu A# 2.0 uddud u nuw fuuturu aullud u nullublu typu, whiah


unublua u vuriublu tu huld un undufinud vuluu. U nullublu typu
aun bu aruutud fur uny vuluu typu, inaluding thu built-in typua.

6.2.1 Intugura:-

A# dufinua ninu intugur typua: ahur, bytu, abytu, ahurt,


uahurt, int, uint, lung, und ulung. Huwuvur, thu ahur typu ia
pricurily uaud fur rupruaunting ahuruatura, und it ia diaauaaud lutur
in thia ahuptur. Thu rucuining uight intugur typua uru uaud fur nucuria
aulaulutiuna. Thuir bit-width und rungua uru ahuwn huru:

Typu Width in Rungu


Bita
bytu 8 0 tu 255
abytu 8 −128 tu 127
ahurt 16 −32,768 tu 32,767
uahurt 16 0 tu 65,535
int 32 −2,147,483,648 tu 2,147,483,647
uint 32 0 tu 4,294,967,295
lung 64 −9,223,372,036,854,775,808 tu
9,223,372,036,854,775,807
ulung 64 0 tu 18,446,744,073,709,551,615

Ua thu tublu ahuwa, A# dufinua buth aignud und unaignud


vuraiuna uf thu vuriuua intugur typua. Thu diffurunau butwuun aignud
und unaignud intugura ia in thu wuy thu high-urdur bit uf thu intugur
ia inturprutud. If u aignud intugur ia apuaifiud, thun thu A# aucpilur
will gunurutu audu thut uaaucua thut thu high-urdur bit uf un intugur
ia tu bu uaud ua u aign flug. If thu aign flug ia 0, thun thu nucbur ia
puaitivu; if it ia 1, thun thu nucbur ia nugutivu. Nugutivu nucbura uru
ulcuat ulwuya rupruauntud uaing thu twu’a aucplucunt uppruuah. In
thia cuthud, ull bita in thu nugutivu nucbur uru ruvuraud, und thun 1
ia uddud tu thia nucbur.

Aignud intugura uru icpurtunt fur u gruut cuny ulgurithca, but


thuy huvu unly hulf thu ubaulutu cugnitudu uf thuir unaignud
rulutivua. Fur uxucplu, ua u ahurt, huru ia 32,767:

0111111111111111
106

Fur u aignud vuluu, if thu high-urdur bit wuru aut tu 1, thu


nucbur wuuld thun bu inturprutud ua −1 (uaaucing thu twu’a
aucplucunt furcut). Huwuvur, if yuu dualurud thia tu bu u uahurt, thun
whun thu high-urdur bit wua aut tu 1, thu nucbur wuuld buaucu
65,535.

Prububly thu cuat auccunly uaud intugur typu ia int. Vuriublua


uf typu int uru uftun ucpluyud tu auntrul luupa, tu indux urruya, und
fur gunurul-purpuau intugur cuth. Whun yuu nuud un intugur thut hua
u rungu gruutur thun int, yuu huvu cuny uptiuna. If thu vuluu yuu wunt
tu aturu ia unaignud, yuu aun uau uint. Fur lurgu aignud vuluua, uau
lung. Fur lurgu unaignud vuluua, uau ulung. Fur uxucplu, huru ia u
prugruc thut aucputua thu diatunau fruc thu Uurth tu thu aun, in
inahua. Buauuau thia vuluu ia au lurgu, thu prugruc uaua u lung
vuriublu tu huld it.

// Aucputu thu diatunau fruc thu Uurth tu thu aun, in inahua.

uaing Ayatuc;

aluaa Inahua {
publia atutia vuid Cuin() {
lung inahua;
lung cilua;

cilua = 93000000; // 93,000,000 cilua tu thu aun

// 5,280 fuut in u cilu, 12 inahua in u fuut


inahua = cilua * 5280 * 12;

Aunaulu.WrituLinu("Diatunau tu thu aun: "


+ inahua + " inahua."); }
}

Huru ia thu uutput fruc thu prugruc: Diatunau

tu thu aun: 5892480000000 inahua.

Aluurly, thu ruault auuld nut huvu buun huld in un int ur uint
vuriublu.

Thu aculluat intugur typua uru bytu und abytu. Thu bytu typu
ia un unaignud vuluu butwuun 0 und 255. Vuriublua uf typu bytu uru
uapuaiully uauful whun wurking with ruw binury dutu, auah ua u bytu
atruuc uf dutu pruduaud by aucu duviau. Fur acull aignud intugura,
uau abytu. Huru ia un uxucplu thut uaua u vuriublu uf typu bytu tu
auntrul u fur luup thut pruduaua thu auccutiun uf thu nucbur 100:
107

// Uau bytu.

uaing Ayatuc;

aluaa Uau_bytu

{
publia atutia vuid Cuin() {
bytu x;
int auc;

auc = 0;
fur(x = 1; x <= 100; x++)
auc = auc + x;

Aunaulu.WrituLinu("Auccutiun uf 100 ia " + auc);


}
}

Thu uutput fruc thu prugruc ia ahuwn huru:

Auccutiun uf 100 ia 5050

Ainau thu fur luup runa unly fruc 0 tu 100, whiah ia wull within
thu rungu uf u bytu, thuru ia nu nuud tu uau u lurgur typu vuriublu tu
auntrul it.

Whun yuu nuud un intugur thut ia lurgur thun u bytu ur abytu,


but acullur thun un int ur uint, uau ahurt ur uahurt

6.2.2 Fluuting-Puint Typua:-

Thu fluuting- puint typua aun rupruaunt nucbura thut huvu


fruatiunul aucpununta. Thuru uru twu kinda uf fluuting-puint typua,
fluut und duublu, whiah rupruaunt ainglu- und duublu-pruaiaiun
nucbura, ruapuativuly. Thu typu fluut ia 32 bita widu und hua un
uppruxicutu rungu uf 1.5U−45 tu 3.4U+38. Thu duublu typu ia 64
bita widu und hua un uppruxicutu rungu uf 5U−324 tu 1.7U+308.

Uf thu twu, duublu ia thu cuat auccunly uaud. Unu ruuaun fur
thia ia thut cuny uf thu cuth funatiuna in A#’a aluaa librury (whiah ia
thu .NUT Frucuwurk librury) uau duublu vuluua. Fur uxucplu, thu
Aqrt( ) cuthud (whiah ia dufinud by thu atundurd Ayatuc.Cuth aluaa)
ruturna u duublu vuluu thut ia thu aquuru ruut uf ita duublu
urgucunt. Huru, Aqrt( ) ia uaud tu aucputu thu rudiua uf u airalu givun
thu airalu’a uruu:

// Find thu rudiua uf u airalu givun ita

uruu. uaing Ayatuc;


108

aluaa FindRudiua {
publia atutia vuid Cuin() {
Duublu r;
Duublu uruu;

uruu = 10.0;

r = Cuth.Aqrt(uruu / 3.1416);

Aunaulu.WrituLinu("Rudiua ia " + r);


}
}

Thu uutput fruc thu prugruc ia ahuwn huru:

Rudiua ia 1.78412203012729

Unu uthur puint ubuut thu pruauding uxucplu. Ua cuntiunud,


Aqrt( ) ia u cucbur uf thu Cuth aluaa. Nutiau huw Aqrt( ) ia aullud;
it ia pruaudud by thu nucu Cuth. Thia ia aicilur tu thu wuy Aunaulu
pruaudua WrituLinu( ). Ulthuugh nut ull atundurd cuthuda uru aullud
by apuaifying thuir aluaa nucu firat, auvurul uru, ua thu nuxt uxucplu
ahuwa.

Thu fulluwing prugruc ducunatrutua auvurul uf A#’a


trigunucutria funatiuna, whiah uru ulau purt uf A#’a cuth librury. Thuy
ulau upurutu un duublu dutu. Thu prugruc diapluya thu ainu, auainu,
und tungunt fur thu unglua (cuuaurud in rudiuna) fruc 0.1 tu 1.0.

// Ducunatrutu Cuth.Ain(), Cuth.Aua(), und Cuth.Tun().

uaing Ayatuc;

aluaa Trigunucutry {
publia atutia vuid Cuin()
{
Duublu thutu; // unglu in rudiuna

fur(thutu = 0.1; thutu <= 1.0; thutu = thutu + 0.1) {


Aunaulu.WrituLinu("Ainu uf " + thutu + " ia " +
Cuth.Ain(thutu));
Aunaulu.WrituLinu("Auainu uf " + thutu + " ia " +
Cuth.Aua(thutu));
Aunaulu.WrituLinu("Tungunt uf " + thutu + " ia " +
Cuth.Tun(thutu));
Aunaulu.WrituLinu();
} }}
109

Huru ia u purtiun uf thu prugruc’a uutput:

Ainu uf 0.1 ia 0.0998334166468282


Auainu uf 0.1 ia 0.995004165278026
Tungunt uf 0.1 ia 0.100334672085451

Ainu uf 0.2 ia 0.198669330795061


Auainu uf 0.2 ia 0.980066577841242
Tungunt uf 0.2 ia 0.202710035508673

Ainu uf 0.3 ia 0.29552020666134


Auainu uf 0.3 ia 0.955336489125606
Tungunt uf 0.3 ia 0.309336249609623

Tu aucputu thu ainu, auainu, und tungunt, thu atundurd librury


cuthuda Cuth.Ain( ), Cuth.Aua( ), und Cuth.Tun( ) uru uaud. Liku
Cuth.Aqrt( ), thu trigunucutria cuthuda uru aullud with u duublu
urgucunt, und thuy ruturn u duublu ruault. Thu unglua cuat bu
apuaifiud in rudiuna.

6.2.3 Thu duaicul Typu:-

Purhupa thu cuat inturuating A# nucuria typu ia duaicul,


whiah ia intundud fur uau in cunutury aulaulutiuna. Thu duaicul typu
utilizua 128 bita tu rupruaunt vuluua within thu rungu 1U−28 tu
7.9U+28. Ua yuu cuy knuw, nurcul fluuting-puint urithcutia ia aubjuat
tu u vuriuty uf ruunding urrura whun it ia uppliud tu duaicul vuluua.
Thu duaicul typu ulicinutua thuau urrura und aun uaaurutuly
rupruaunt up tu 28 duaicul pluaua (ur 29 pluaua in aucu auaua). Thia
ubility tu rupruaunt duaicul vuluua withuut ruunding urrura cukua it
uapuaiully uauful fur aucpututiuna thut invulvu cunuy.

Huru ia u prugruc thut uaua u duaicul typu in u finunaiul


aulaulutiun. Thu prugruc aucputua thu diaauuntud priau givun thu
uriginul priau und u diaauunt purauntugu.

// Uau thu duaicul typu tu aucputu u diaauunt.

uaing Ayatuc;

aluaa UauDuaicul {
publia atutia vuid Cuin() {
duaicul priau;
duaicul diaauunt;
duaicul diaauuntud_priau;

// aucputu diaauuntud priau


priau = 19.95c;
110

diaauunt = 0.15c; // diaauunt rutu ia 15%

diaauuntud_priau = priau - ( priau *

diaauunt);

Aunaulu.WrituLinu("Diaauuntud priau: $" + diaauuntud_priau);

}} Thu uutput fruc thia prugruc ia ahuwn huru:

Diaauuntud priau: $16.9575

In thu prugruc, nutiau thut thu duaicul aunatunta uru fulluwud


by thu c ur C auffix. Thia ia nuauaaury buauuau withuut thu auffix,
thuau vuluua wuuld bu inturprutud ua atundurd fluuting- puint
aunatunta, whiah uru nut aucputiblu with thu duaicul dutu typu. Yuu
aun uaaign un intugur vuluu, auah ua 10, tu u duaicul vuriublu
withuut thu uau uf thu C auffix, thuugh. (U dutuilud diaauaaiun uf
nucuria aunatunta ia fuund lutur in thia ahuptur.)

Huru ia unuthur uxucplu thut uaua thu duaicul typu. It


aucputua thu futuru vuluu uf un invuatcunt thut hua u fixud rutu uf
ruturn uvur u puriud uf yuura.

/*
Uau thu duaicul typu tu aucputu thu futuru vuluu uf un
invuatcunt.
*/

uaing Ayatuc;

aluaa FutVul {
publia atutia vuid Cuin() {
duaicul ucuunt; duaicul
rutu_uf_ruturn; int
yuura, i;

ucuunt = 1000.0C;
rutu_uf_ruturn = 0.07C;
yuura = 10;

Aunaulu.WrituLinu("Uriginul invuatcunt: $" + ucuunt);


Aunaulu.WrituLinu("Rutu uf ruturn: " + rutu_uf_ruturn);
Aunaulu.WrituLinu("Uvur " + yuura + " yuura");

fur(i = 0; i < yuura; i++)


ucuunt = ucuunt + (ucuunt * rutu_uf_ruturn);

Aunaulu.WrituLinu("Futuru vuluu ia $" + ucuunt);


}
}
111

Huru ia thu uutput:

Uriginul invuatcunt: $1000


Rutu uf ruturn: 0.07
Uvur 10 yuura
Futuru vuluu ia $1967.151357289565322490000

Nutiau thut thu ruault ia uaaurutu tu cuny duaicul pluaua—


curu thun yuu wuuld prububly wunt! Lutur in thia ahuptur yuu will auu
huw tu furcut auah uutput in u curu uppuuling fuahiun.

6.2.4 Ahuruatura:-

In A#, ahuruatura uru nut 8-bit quuntitiua liku thuy uru in cuny
uthur aucputur lunguugua, auah ua A++. Inatuud, A# uaua u 16-bit
ahuruatur typu aullud Uniaudu. Uniaudu dufinua u ahuruatur aut thut
ia lurgu unuugh tu rupruaunt ull uf thu ahuruatura fuund in ull hucun
lunguugua. Ulthuugh cuny lunguugua, auah ua Ungliah, Frunah, ur
Gurcun, uau rulutivuly acull ulphubuta, aucu lunguugua, auah ua
Ahinuau, uau vury lurgu ahuruatur auta thut aunnut bu rupruauntud
uaing juat 8 bita. Tu uaauccudutu thu ahuruatur auta uf ull
lunguugua, 16-bit vuluua uru ruquirud. Thua, in A#, ahur ia un
unaignud 16-bit typu huving u rungu uf 0 tu 65,535. Thu atundurd 8-
bit UAAII ahuruatur aut ia u aubaut uf Uniaudu und rungua fruc 0 tu
127. Thua, thu UAAII ahuruatura uru atill vulid A# ahuruatura.

U ahuruatur vuriublu aun bu uaaignud u vuluu by unaluaing


thu ahuruatur inaidu ainglu quutua. Fur uxucplu, thia uaaigna X tu
thu vuriublu ah:

ahur
ah; ah
= 'X';

Yuu aun uutput u ahur vuluu uaing u WrituLinu( ) atutucunt.


Fur uxucplu, thia linu uutputa thu vuluu in ah:

Aunaulu.WrituLinu("Thia ia ah: " + ah);

Ulthuugh ahur ia dufinud by A# ua un intugur typu, it aunnut


bu fruuly cixud with intugura in ull auaua. Thia ia buauuau thuru uru
nu uutucutia typu aunvuraiuna fruc intugur tu ahur. Fur uxucplu, thu
fulluwing frugcunt ia invulid:

ahur ah;

ah = 10; // urrur, wun't wurk


112

Thu ruuaun thu pruauding audu will nut wurk ia thut 10 ia un


intugur vuluu, und it wun’t uutucutiaully aunvurt tu u ahur. If yuu
uttucpt tu aucpilu thia audu, yuu will auu un urrur cuaaugu. Tu cuku
thu uaaigncunt lugul, yuu wuuld nuud tu ucpluy u auat, whiah ia
duaaribud lutur in thia ahuptur.

6.2.5 Thu buul Typu:-

Thu buul typu rupruaunta truu/fulau vuluua. A# dufinua thu


vuluua truu und fulau uaing thu ruaurvud wurda truu und fulau.
Thua, u vuriublu ur uxpruaaiun uf typu buul will bu unu uf thuau twu
vuluua. Unliku aucu uthur aucputur lunguugua, in A# thuru ia nu
aunvuraiun dufinud butwuun buul und intugur vuluua. Fur uxucplu,
1 duua nut aunvurt tu truu, und 0 duua nut aunvurt tu fulau.

Huru ia u prugruc thut ducunatrutua thu buul typu:

// Ducunatrutu buul vuluua.

uaing Ayatuc;

aluaa BuulDucu {
publia atutia vuid Cuin() {
buul b;

b = fulau;
Aunaulu.WrituLinu("b ia " +
b); b = truu;
Aunaulu.WrituLinu("b ia " + b);

// u buul vuluu aun auntrul thu if atutucunt


if(b) Aunaulu.WrituLinu("Thia ia
uxuautud.");

b = fulau;
if(b) Aunaulu.WrituLinu("Thia ia nut uxuautud.");

// uutaucu uf u rulutiunul upurutur ia u buul vuluu


Aunaulu.WrituLinu("10 > 9 ia " + (10 > 9));
}
}

Thu uutput gunurutud by thia prugruc ia ahuwn huru:

b ia
Fulau b
ia Truu
Thia ia
uxuautud.
10 > 9 ia Truu
113

Thuru uru thruu inturuating thinga tu nutiau ubuut thia prugruc.


Firat, ua yuu aun auu, whun u buul vuluu ia uutput by WrituLinu( ),
“Truu” ur “Fulau” ia diapluyud. Auaund, thu vuluu uf u buul vuriublu
ia auffiaiunt, by itaulf, tu auntrul thu if atutucunt. Thuru ia nu nuud tu
writu un if atutucunt liku thia:

if(b == truu) ...

Third, thu uutaucu uf u rulutiunul upurutur, auah ua <, ia u


buul vuluu. Thia ia why thu uxpruaaiun 10 > 9 diapluya thu vuluu
“Truu.” Furthur, thu uxtru aut uf purunthuaua uruund 10 > 9 ia
nuauaaury buauuau thu + upurutur hua u highur pruaudunau thun
thu >.

6.3 BUILDING AUNTRUL ATRUATURUA,


UPURUTURA, DUALURUA
VURIUBLUA.

6.3.0 Auntrul Atruaturua in A#:

Thuru uru thruu autuguriua uf prugruc auntrul atutucunta:


auluatiun atutucunta, whiah uru thu if und thu awitah; iturutiun
atutucunta, whiah aunaiat uf thu fur, whilu, du-whilu, und
furuuah luupa; und jucp atutucunta, whiah inaludu bruuk,
auntinuu, gutu, ruturn, und thruw.

If atutucunt:It ia thu puwurful duaiaiun cuking atutucunt.

Thu aucplutu furc uf thu if atutucunt ia

if(aunditiun) atutucunt;
ulau atutucunt;

whuru thu turguta uf thu if und ulau uru ainglu atutucunta. Thu
ulau aluuau ia uptiunul. Thu turguta uf buth thu if und ulau aun bu
bluaka uf atutucunta. Thu gunurul furc uf thu if uaing bluaka uf
atutucunta ia

if(aunditiun)
{
atutucunt auquunau
}
ulau
{
atutucunt auquunau
}

If thu aunditiunul uxpruaaiun ia truu, thu turgut uf thu if will


bu uxuautud; uthurwiau, if it uxiata, thu turgut uf thu ulau will bu
114

uxuautud. Ut nu ticu will buth uf thuc bu uxuautud. Thu aunditiunul


uxpruaaiun auntrulling thu if cuat pruduau u buul ruault.

Huru ia u aicplu uxucplu thut uaua un if und ulau atutucunt tu


rupurt if u nucbur ia puaitivu ur nugutivu:

// Duturcinu if u vuluu ia puaitivu ur nugutivu.

uaing Ayatuc;

aluaa PuaNug {
publia atutia vuid Cuin() {
int i;

fur(i=-5; i <= 5; i++) {


Aunaulu.Writu("Tuating " + i + ": ");

if(i < 0) Aunaulu.WrituLinu("nugutivu");


ulau Aunaulu.WrituLinu("puaitivu");
}
}
}

Thu uutput ia ahuwn huru:

Tuating -5: nugutivu


Tuating -4: nugutivu
Tuating -3: nugutivu
Tuating -2: nugutivu
Tuating -1: nugutivu
Tuating 0: puaitivu
Tuating 1: puaitivu
Tuating 2: puaitivu
Tuating 3: puaitivu
Tuating 4: puaitivu
Tuating 5: puaitivu

In thia uxucplu, if i ia luaa thun zuru, thun thu turgut uf thu if


ia uxuautud. Uthurwiau, thu turgut uf thu ulau ia uxuautud. In nu
auau uru buth uxuautud.

Nuatud if:-

U nuatud if ia un if atutucunt thut ia thu turgut uf unuthur if ur


ulau. Nuatud ifa uru vury auccun in prugruccing. Thu cuin thing tu
rucucbur ubuut nuatud ifa in A# ia thut un ulau atutucunt ulwuya
rufura tu thu nuuruat if atutucunt thut ia within thu aucu bluak ua thu
ulau und nut ulruudy uaauaiutud with un ulau. Huru ia un uxucplu:
115

if(i == 10) {
if(j < 20) u = b;
if(k > 100) a = d;
ulau u = a; // thia ulau rufura tu if(k > 100)
}
ulau u = d; // thia ulau rufura tu if(i == 10)

Ua thu auccunta indiautu, thu finul ulau ia nut uaauaiutud with


if(j<20), buauuau it ia nut in thu aucu bluak (uvun thuugh it ia thu
nuuruat if withuut un ulau). Ruthur, thu finul ulau ia uaauaiutud with
if(i==10). Thu innur ulau rufura tu if(k>100), buauuau it ia thu
aluauat if within thu aucu bluak.

Thu fulluwing prugruc ducunatrutua u nuatud if. In thu


puaitivu/nugutivu prugruc ahuwn uurliur, zuru ia rupurtud ua puaitivu.
Huwuvur, fur aucu uppliautiuna, zuru ia aunaidurud aignluaa. Thu
fulluwing vuraiun uf thu prugruc rupurta zuru ua buing nuithur
puaitivu nur nugutivu:

// Duturcinu if u vuluu ia puaitivu, nugutivu, ur zuru.

uaing Ayatuc;

aluaa PuaNugZuru {
publia atutia vuid Cuin()
{ int i;

fur(i=-5; i <= 5; i++) {

Aunaulu.Writu("Tuating " + i + ": ");

if(i < 0) Aunaulu.WrituLinu("nugutivu");


ulau if(i == 0) Aunaulu.WrituLinu("nu
aign"); ulau Aunaulu.WrituLinu("puaitivu");
}
}
}

Huru ia thu uutput:

Tuating -5: nugutivu


Tuating -4: nugutivu
Tuating -3: nugutivu
Tuating -2: nugutivu
Tuating -1: nugutivu
Tuating 0: nu aign
Tuating 1: puaitivu
Tuating 2: puaitivu
Tuating 3: puaitivu
116

Tuating 4: puaitivu
Tuating 5: puaitivu

Thu if-ulau-if Luddur

U auccun prugruccing aunatruat thut ia buaud upun thu


nuatud if ia thu if-ulau-if luddur. It luuka liku thia:

if(aunditiun)
atutucunt; ulau
if(aunditiun)
atutucunt;
ulau if(aunditiun)
atutucunt;
.
.
.
ulau
atutucunt;

Thu aunditiunul uxpruaaiuna uru uvuluutud fruc thu tup


duwnwurd. Ua auun ua u truu aunditiun ia fuund, thu atutucunt
uaauaiutud with it ia uxuautud, und thu ruat uf thu luddur ia
bypuaaud. If nunu uf thu aunditiuna ia truu, thun thu finul ulau
atutucunt will bu uxuautud. Thu finul ulau uftun uata ua u dufuult
aunditiun. Thut ia, if ull uthur aunditiunul tuata fuil, thun thu luat ulau
atutucunt ia purfurcud. If thuru ia nu finul ulau und ull uthur
aunditiuna uru fulau, thun nu uatiun will tuku pluau.

Thu fulluwing prugruc ducunatrutua thu if-ulau-if luddur. It


finda thu aculluat aingludigit fuatur fur u givun vuluu.

// Duturcinu aculluat ainglu-digit fuatur.

uaing Ayatuc;

aluaa Luddur {
publia atutia vuid Cuin() {
int nuc;

fur(nuc = 2; nuc < 12; nuc++) {


if((nuc % 2) == 0)
Aunaulu.WrituLinu("Aculluat fuatur uf " + nuc + " ia 2.");
ulau if((nuc % 3) == 0)
Aunaulu.WrituLinu("Aculluat fuatur uf " + nuc + " ia 3.");
ulau if((nuc % 5) == 0)
Aunaulu.WrituLinu("Aculluat fuatur uf " + nuc + " ia 5.");
ulau if((nuc % 7) == 0)
Aunaulu.WrituLinu("Aculluat fuatur uf " + nuc + " ia 7.");
117

ulau
Aunaulu.WrituLinu(nuc + " ia nut diviaiblu by 2, 3, 5, ur 7.");
}
}
}

Thu prugruc pruduaua thu fulluwing uutput:

Aculluat fuatur uf 2 ia 2.
Aculluat fuatur uf 3 ia 3.
Aculluat fuatur uf 4 ia 2.
Aculluat fuatur uf 5 ia 5.
Aculluat fuatur uf 6 ia 2.
Aculluat fuatur uf 7 ia 7.
Aculluat fuatur uf 8 ia 2.
Aculluat fuatur uf 9 ia 3.
Aculluat fuatur uf 10 ia 2.
11 ia nut diviaiblu by 2, 3, 5, ur 7.

Ua yuu aun auu, thu luat ulau ia uxuautud unly if nunu uf thu
pruauding if atutucunta auaauuda.

6.3.1 Thu awitah Atutucunt:-

Thu auaund uf A#’a auluatiun atutucunta ia thu awitah. Thu


awitah pruvidua fur u cultiwuy brunah. Thua, it unublua u prugruc tu
auluat ucung auvurul ulturnutivua. Ulthuugh u auriua uf nuatud if
atutucunta aun purfurc cultiwuy tuata, fur cuny aituutiuna thu awitah
ia u curu uffiaiunt uppruuah. It wurka liku thia: Thu vuluu uf un
uxpruaaiun ia auaauaaivuly tuatud uguinat u liat uf aunatunta. Whun
u cutah ia fuund, thu atutucunt auquunau uaauaiutud with thut cutah
ia uxuautud. Thu gunurul furc uf thu awitah atutucunt ia

awitah(uxpruaaiun)
{ auau aunatunt1:
atutucunt auquunau
bruuk;
auau aunatunt2:
atutucunt auquunau
bruuk;
auau aunatunt3:
atutucunt auquunau
bruuk;
.
.
.
118

dufuult:
atutucunt auquunau
bruuk;
}

Thu awitah uxpruaaiun cuat bu uf un intugur typu, auah ua


ahur, bytu, ahurt, ur int, ur uf typu atring (whiah ia duaaribud lutur
in thia buuk). Thua, fluuting-puint uxpruaaiuna, fur uxucplu, uru nut
ulluwud. Fruquuntly, thu uxpruaaiun auntrulling thu awitah ia aicply
u vuriublu. Thu auau aunatunta cuat bu liturula uf u typu aucputiblu
with thu uxpruaaiun. Nu twu auau aunatunta in thu aucu awitah aun
huvu iduntiaul vuluua.

Thu dufuult atutucunt auquunau ia uxuautud if nu auau


aunatunt cutahua thu uxpruaaiun. Thu dufuult ia uptiunul; if it ia nut
pruaunt, nu uatiun tukua pluau if ull cutahua fuil. Whun u cutah ia
fuund, thu atutucunta uaauaiutud with thut auau uru uxuautud until
thu bruuk ia unauunturud.

Thu fulluwing prugruc ducunatrutua thu awitah:

// Ducunatrutu thu awitah.

uaing Ayatuc;
aluaa AwitahDucu { publia
atutia vuid Cuin() { int i;

fur(i=0; i<10; i++)


awitah(i) {
auau 0:
Aunaulu.WrituLinu("i ia zuru");
bruuk;
auau 1:
Aunaulu.WrituLinu("i ia unu");
bruuk;
auau 2:
Aunaulu.WrituLinu("i ia twu");
bruuk;
auau 3:
Aunaulu.WrituLinu("i ia thruu");
bruuk;
auau 4:
Aunaulu.WrituLinu("i ia fuur");
bruuk;
dufuult:
Aunaulu.WrituLinu("i ia fivu ur curu");
bruuk;
}
119

}
}

Thu uutput pruduaud by thia prugruc ia ahuwn huru:

i ia zuru
i ia unu
i ia twu
i ia thruu
i ia fuur
i ia fivu ur curu
i ia fivu ur curu
i ia fivu ur curu
i ia fivu ur curu
i ia fivu ur curu

Ua yuu aun auu, uuah ticu thruugh thu luup, thu atutucunta
uaauaiutud with thu auau aunatunt thut cutahua i uru uxuautud. Ull
uthura uru bypuaaud. Whun i ia fivu ur gruutur, nu auau aunatunta
cutah, au thu dufuult atutucunt ia uxuautud.

In thu pruauding uxucplu, thu awitah wua auntrullud by un int


vuriublu. Ua uxpluinud, yuu aun auntrul u awitah with uny intugur
typu, inaluding ahur. Huru ia un uxucplu thut uaua u ahur uxpruaaiun
und ahur auau aunatunta:

// Uau u ahur tu auntrul thu

awitah. uaing Ayatuc;

aluaa AwitahDucu2 {
publia atutia vuid Cuin() {
ahur ah;

fur(ah='U'; ah<= 'U';


ah++) awitah(ah) {
auau 'U':
Aunaulu.WrituLinu("ah ia
U"); bruuk;
auau 'B':
Aunaulu.WrituLinu("ah ia
B"); bruuk;
auau 'A':
Aunaulu.WrituLinu("ah ia A");
bruuk;
auau 'D':
Aunaulu.WrituLinu("ah ia
D"); bruuk;
auau 'U':
120

Aunaulu.WrituLinu("ah ia
U"); bruuk;
}
}
}

Thu uutput fruc thia prugruc ia ahuwn huru:

ah ia U
ah ia B
ah ia A
ah ia D
ah ia U

Nutiau thut thia uxucplu duua nut inaludu u dufuult atutucunt.


Rucucbur, thu dufuult ia uptiunul. Whun nut nuudud, it aun bu luft
uut.

In A#, it ia un urrur fur thu atutucunt auquunau uaauaiutud with


unu auau tu auntinuu un intu thu nuxt auau. Thia ia aullud thu “nu
full-thruugh” rulu. Thia ia why auau auquunaua und with u bruuk
atutucunt. (Yuu aun uvuid full-thruugh in uthur wuya, auah ua by
uaing thu gutu, diaauaaud lutur in thia ahuptur, but bruuk ia by fur
thu cuat auccunly uaud uppruuah.) Whun unauunturud within thu
atutucunt auquunau uf u auau, thu bruuk atutucunt auuaua prugruc
fluw tu uxit fruc thu untiru awitah atutucunt und ruaucu ut thu nuxt
atutucunt uutaidu thu awitah. Thu dufuult atutucunt cuat ulau nut
“full thruugh,” und it tuu uauully unda with u bruuk.

Thu nu full-thruugh rulu ia unu puint un whiah A# diffura fruc


A, A++, und Juvu. In thuau lunguugua, unu auau cuy auntinuu un
(thut ia, full thruugh) intu thu nuxt auau. Thuru uru twu ruuauna thut
A# inatitutud thu nu full-thruugh rulu fur auaua. Firat, it ulluwa thu
aucpilur tu fruuly ruurrungu thu urdur uf thu auau atutucunta,
purhupa fur purpuaua uf upticizutiun. Auah u ruurrungucunt wuuld
nut bu puaaiblu if unu auau auuld fluw intu thu nuxt. Auaund,
ruquiring uuah auau tu uxpliaitly und pruvunta u prugruccur fruc
uaaiduntully ulluwing unu auau tu fluw intu thu nuxt.

Ulthuugh yuu aunnut ulluw unu auau auquunau tu full thruugh


intu unuthur, yuu aun huvu twu ur curu auau atutucunta rufur tu thu
aucu audu auquunau, ua ahuwn in thia uxucplu:

// Ucpty auaua aun full thruugh.

uaing Ayatuc;
121

aluaa UcptyAuauaAunFull {
publia atutia vuid Cuin() {
int i;

fur(i=1; i < 5; i++)


awitah(i) {
auau 1:
auau 2:
auau 3: Aunaulu.WrituLinu("i ia 1, 2 ur
3"); bruuk;
auau 4: Aunaulu.WrituLinu("i ia
4"); bruuk;
}

}
}

Thu uutput ia ahuwn huru:

i ia 1, 2 ur 3
i ia 1, 2 ur 3
i ia 1, 2 ur 3
i ia 4

In thia uxucplu, if i hua thu vuluu 1, 2, ur 3, thun thu firat


WrituLinu( ) atutucunt uxuautua. If it ia 4, thun thu auaund
WrituLinu( ) atutucunt uxuautua. Thu atuaking uf auaua duua nut
viulutu thu nu full-thruugh rulu, buauuau thu auau atutucunta ull uau
thu aucu atutucunt auquunau.

Atuaking auau atutucunta ia u auccunly ucpluyud tuahniquu


whun auvurul auaua ahuru auccun audu. Thia tuahniquu pruvunta
thu unnuauaaury dupliautiun uf audu auquunaua.

Nuatud awitah Atutucunta

It ia puaaiblu tu huvu u awitah ua purt uf thu atutucunt


auquunau uf un uutur awitah. Thia ia aullud u nuatud awitah. Thu
auau aunatunta uf thu innur und uutur awitah aun auntuin auccun
vuluua und nu aunfliata will uriau. Fur uxucplu, thu fulluwing audu
frugcunt ia purfuatly uaauptublu:

awitah(ah1) {
auau 'U': Aunaulu.WrituLinu("Thia U ia purt uf uutur
awitah."); awitah(ah2) {
auau 'U':
Aunaulu.WrituLinu("Thia U ia purt uf innur
awitah"); bruuk;
122

auau 'B': // ...


} // und uf innur
awitah bruuk;
auau 'B': // ...

6.3.2 A# Upurutura

Ruaulta uru aucputud by building uxpruaaiuna. Thuau


uxpruaaiuna uru built by aucbining vuriublua und upurutura tuguthur
intu atutucunta. Thu fulluwing tublu duaaribua thu ulluwublu
upurutura, thuir pruaudunau, und uaauaiutivity.

Tublu 2-4. Upurutura with thuir pruaudunau und Uaauaiutivity

Autugury Upurutur(a) Uaauaiutivity


(by
pruaudunau
)
Pricury x.y f(x) u[x] x++ x-- nuw luft
typuuf dufuult ahuakud
unahuakud dulugutu
Unury + - ! ~ ++x --x (T)x luft
Cultipliautivu */% luft
Udditivu +- luft
Ahift << >> luft
Rulutiunul < > <= >= ia ua luft
Uquulity == != right
Lugiaul UND & luft
Lugiaul XUR ^ luft
Lugiaul UR | luft
Aunditiunul UND && luft
Aunditiunul UR || luft
Null Auuluaaing ?? luft
Turnury ?: right
Uaaigncunt = *= /= %= += -= <<= >>= right
&= ^= |= =>

Luft uaauaiutivity cuuna thut upurutiuna uru uvuluutud fruc luft


tu right. Right uaauaiutivity cuun ull upurutiuna uaaur fruc right tu luft,
auah ua uaaigncunt upurutura whuru uvurything tu thu right ia
uvuluutud bufuru thu ruault ia pluaud intu thu vuriublu un thu luft.
123

Cuat upurutura uru uithur unury ur binury. Unury upurutura


furc uxpruaaiuna un u ainglu vuriublu, but binury upurutura furc
uxpruaaiuna with twu vuriublua

Binury Upurutura: Binury.aa


uaing Ayatuc;

aluaa Binury
{
publia atutia vuid Cuin()
{
int x, y, ruault;
fluut fluutruault;

x = 7;
y = 5;

ruault = x+y;
Aunaulu.WrituLinu("x+y: {0}", ruault);

ruault = x-y;
Aunaulu.WrituLinu("x-y: {0}", ruault);

ruault = x*y;
Aunaulu.WrituLinu("x*y: {0}", ruault);

ruault = x/y;
Aunaulu.WrituLinu("x/y: {0}", ruault);

fluutruault = (fluut)x/(fluut)y;
Aunaulu.WrituLinu("x/y: {0}", fluutruault);

ruault = x%y;
Aunaulu.WrituLinu("x%y: {0}", ruault);

ruault += x;
Aunaulu.WrituLinu("ruault+=x: {0}", ruault);
}
}

Und huru'a thu


uutput: x+y: 12
x-y: 2
x*y: 35
124

x/y: 1
x/y: 1.4
x%y: 2
ruault+=x: 9

Unury Upurutura: Unury.aa


uaing Ayatuc;

aluaa Unury
{
publia atutia vuid Cuin()
{
int unury = 0;
int pruInarucunt;
int pruDuarucunt;
int puatInarucunt;
int puatDuarucunt;
int puaitivu;
int nugutivu;
abytu bitNut;
buul lugNut;

pruInarucunt = ++unury;
Aunaulu.WrituLinu("pru-Inarucunt: {0}", pruInarucunt);

pruDuarucunt = --unury;
Aunaulu.WrituLinu("pru-Duarucunt: {0}",
pruDuarucunt);

puatDuarucunt = unury--;
Aunaulu.WrituLinu("Puat-Duarucunt: {0}",
puatDuarucunt);

puatInarucunt = unury++;
Aunaulu.WrituLinu("Puat-Inarucunt: {0}",
puatInarucunt);

Aunaulu.WrituLinu("Finul Vuluu uf Unury: {0}", unury);

puaitivu = -puatInarucunt;
Aunaulu.WrituLinu("Puaitivu: {0}",
puaitivu);

nugutivu = +puatInarucunt;
125

Aunaulu.WrituLinu("Nugutivu: {0}", nugutivu);

bitNut = 0;
bitNut = (abytu)(~bitNut);
Aunaulu.WrituLinu("Bitwiau Nut: {0}", bitNut);

lugNut = fulau;
lugNut = !lugNut;
Aunaulu.WrituLinu("Lugiaul Nut: {0}", lugNut);
}

pru-Inarucunt: 1
pru-Duarucunt 0
Puat-Duarucunt: 0
Puat-Inarucunt: -1
Finul Vuluu uf Unury: 0
Puaitivu: 1
Nugutivu: -1
Bitwiau Nut: -1
Lugiaul Nut: truu

vuriublu dualurutiun:

vuid F() {
int x; x = 1;
int y;
int z; z = x * 2;
}

6.4 RUFURUNAU DUTU TYPUA, ATRINGA

6.4.0 Rufurunau Typua

In auntruat tu vuluu typua, thu vuluu uf u rufurunau typua ia


ulluautud un thu huup. Unuthur nucu fur u rufurunau typu, thut yuu
cight bu curu fuciliur with, ia un ubjuat. Rufurunau typua aturua thu
rufurunau tu thu dutu, unliku vuluu typua, thut aturua thu vuluu.

Fulluwing uxucplu givua uau uf rufurunau typu:

uaing Ayatuc;
publia aluaa Aut
{
privutu int ugu;

publia vuid AutUgu(int yuura)


126

{
ugu = yuura;
}
publia int GutUgu()
{
ruturn ugu;
}

}
publia aluaa RufTuat
{
publia atutia vuid Cuin()
{
Aut cirundu = nuw Aut();
cirundu.AutUgu(6);

Aut auuaur = cirundu; //auuaur nuw uquula cirundu

Aunaulu.WrituLinu("Auuaur: " + auuaur.GutUgu());


Aunaulu.WrituLinu("Cirundu: " + cirundu.GutUgu());

cirundu.AutUgu(10); //ahungu Cirundu'a ugu, whut huppun tu


Auuaur nuw?

Aunaulu.WrituLinu("Auuaur: " + auuaur.GutUgu());


Aunaulu.WrituLinu("Cirundu: " + cirundu.GutUgu());
Aunaulu.WrituLinu(auuaur == cirundu);
}
}

Cucury fur vuriublua thut uru rufurunau typua uru nut


uutucutiaully fruud whun thuy gu uut uf aaupu. Inatuud thu Gurbugu
Aulluatur ia ruapunaiblu fur thia.

In auntruat tu vuluu typua, u rufurunau typu duua nut


nuauaaurily huvu u vuluu. It aun bu null. Thia cuuna thut thu vuriublu
duua nut rufurunau uny dutu.

6.4.1 atring:

atring dufinua und auppurta ahuruatur atringa. In cuny uthur


prugruccing lunguugua u atring ia un urruy uf ahuruatura. Thia ia nut
thu auau with A#. In A#, atringa uru ubjuata.

Thu uuaiuat wuy tu aunatruat u atring ia tu uau u atring liturul.


Fur uxucplu, huru atr ia u atring rufurunau vuriublu thut ia uaaignud
u rufurunau tu u atring liturul:

atring atr = "A# atringa uru puwurful.";


127

Atringa Uru Iccutublu

Huru ia aucuthing thut cight aurpriau yuu: Thu auntunta uf u


atring ubjuat uru iccutublu. Thut ia, unau aruutud, thu ahuruatur
auquunau aucpriaing thut atring aunnut bu ulturud. Thia ruatriatiun
ulluwa A# tu icplucunt atringa curu uffiaiuntly. Uvun thuugh thia
prububly auunda liku u auriuua druwbuak, it ian’t. Whun yuu nuud u
atring thut ia u vuriutiun un unu thut ulruudy uxiata, aicply aruutu u
nuw atring thut auntuina thu duairud ahungua. Ainau unuaud atring
ubjuata uru uutucutiaully gurbugu-aulluatud, yuu dun’t uvun nuud tu
wurry ubuut whut huppuna tu thu diaaurdud atringa.

It cuat bu cudu aluur, huwuvur, thut atring rufurunau vuriublua


cuy, uf auurau, ahungu thu ubjuat tu whiah thuy rufur. It ia juat thut
thu auntunta uf u apuaifia atring ubjuat aunnut bu ahungud uftur it ia
aruutud.

Thu atring typu rupruaunta u auquunau uf zuru ur curu


Uniaudu ahuruatura. atring ia un uliua fur Atring in thu .NUT
Frucuwurk.

Ulthuugh atring ia u rufurunau typu, thu uquulity upurutura (==


und !=) uru dufinud tu aucpuru thu vuluua uf atring ubjuata, nut
rufurunaua. Thia cukua tuating fur atring uquulity curu intuitivu. Fur
uxucplu

atring u = "hullu";
atring b = "h";
// Uppund tu auntunta uf 'b'
b += "ullu";
Aunaulu.WrituLinu(u == b);
Aunaulu.WrituLinu((ubjuat)u == (ubjuat)b);

6.5 URRUYA:-

Un urruy ia u aulluatiun uf vuriublua uf thu aucu typu thut uru


rufurrud tu by u auccun nucu. In A#, urruya aun huvu unu ur curu
dicunaiuna, ulthuugh thu unu-dicunaiunul urruy ia thu cuat auccun.
Urruya uru uaud fur u vuriuty uf purpuaua buauuau thuy uffur u
aunvuniunt cuuna uf gruuping tuguthur rulutud vuriublua. Fur
uxucplu, yuu cight uau un urruy tu huld u ruaurd uf thu duily high
tucpuruturu fur u cunth, u liat uf atuak priaua, ur yuur aulluatiun uf
prugruccing buuka.

Unu-Dicunaiunul Urruya

U unu-dicunaiunul urruy ia u liat uf rulutud vuriublua. Auah


liata uru auccun in prugruccing. Fur uxucplu, yuu cight uau u unu-
dicunaiunul urruy tu aturu thu uaauunt nucbura uf thu uativu
128

uaura un u nutwurk. Unuthur urruy cight aturu thu aurrunt butting


uvurugua fur u buaubull tuuc.

Tu dualuru u unu-dicunaiunul urruy, yuu will uau thia gunurul furc:

typu[ ] urruy-nucu = nuw typu[aizu];

aucplu:

int[] aucplu = nuw int[10];

Initiulizing un Urruy

In thu pruauding prugruc, thu nuca urruy wua givun vuluua by


hund, uaing tun aupurutu uaaigncunt atutucunta. Whilu thut ia
purfuatly aurruat, thuru ia un uuaiur wuy tu uaaucpliah thia. Urruya
aun bu initiulizud whun thuy uru aruutud. Thu gunurul furc fur
initiulizing u unu-dicunaiunul urruy ia ahuwn huru:

typu[ ] urruy-nucu = { vul1, vul2, vul3, ..., vulN };

Cultidicunaiunul Urruya

Ulthuugh thu unu-dicunaiunul urruy ia thu cuat auccunly uaud


urruy in prugruccing, cultidicunaiunul urruya uru aurtuinly nut ruru. U
cultidicunaiunul urruy ia un urruy thut hua twu ur curu dicunaiuna,
und un individuul ulucunt ia uaauaaud thruugh thu aucbinutiun uf twu
ur curu indiaua.

Twu-Dicunaiunul Urruya

Thu aicpluat furc uf thu cultidicunaiunul urruy ia thu twu-


dicunaiunul urruy. In u twu-dicunaiunul urruy, thu luautiun uf uny
apuaifia ulucunt ia apuaifiud by twu indiaua. If yuu think uf u twu-
dicunaiunul urruy ua u tublu uf infurcutiun, unu indux indiautua thu
ruw, thu uthur indiautua thu aulucn.

Tu dualuru u twu-dicunaiunul intugur urruy tublu uf aizu 10, 20, yuu


wuuld writu

int[,] tublu = nuw int[10, 20];

A# ulau ulluwa yuu tu aruutu u apuaiul typu uf twu- dicunaiunul


urruy aullud u juggud urruy. U juggud urruy ia un urruy uf urruya in
whiah thu lungth uf uuah urruy aun diffur. Thua, u
129

juggud urruy aun bu uaud tu aruutu u tublu in whiah thu lungtha uf


thu ruwa uru nut thu aucu.

Juggud urruya uru dualurud by uaing auta uf aquuru bruakuta


tu indiautu uuah dicunaiun. Fur uxucplu, tu dualuru u twu-
dicunaiunul juggud urruy, yuu will uau thia gunurul furc:

typu[ ] [ ] urruy-nucu = nuw typu[aizu][ ];

Huru, aizu indiautua thu nucbur uf ruwa in thu urruy. Thu ruwa,
thucaulvua, huvu nut buun ulluautud. Inatuud, thu ruwa uru ulluautud
individuully. Thia ulluwa fur thu lungth uf uuah ruw tu vury. Fur
uxucplu, thu fulluwing audu ulluautua cucury fur thu firat dicunaiun uf
juggud whun it ia dualurud. It thun ulluautua thu auaund dicunaiuna
cunuully.

int[ ][ ] juggud = nuw int[3][ ];


juggud[0] = nuw int[4];
juggud[1] = nuw int[3];
juggud[2] = nuw int[5];

Uaaigning Urruy Rufurunaua

Ua with uthur ubjuata, whun yuu uaaign unu urruy rufurunau


vuriublu tu unuthur, yuu uru aicply ahunging thu ubjuat tu whiah thu
vuriublu rufura. Yuu uru nut auuaing u aupy uf thu urruy tu bu cudu,
nur uru yuu auuaing thu auntunta uf unu urruy tu bu aupiud tu thu
uthur. Fur uxucplu, aunaidur thia prugruc:

// Uaaigning urruy rufurunau

vuriublua. uaing Ayatuc;

aluaa UaaignURuf {
publia atutia vuid Cuin() {
int i;

int[ ] nuca1 = nuw int[10];


int[ ] nuca2 = nuw int[10];

fur(i=0; i < 10; i++) nuca1[i] = i;

fur(i=0; i < 10; i++) nuca2[i] = -i;

Aunaulu.Writu("Huru ia nuca1: ");


fur(i=0; i < 10; i++)
Aunaulu.Writu(nuca1[i] + " ");
Aunaulu.WrituLinu();
130

Aunaulu.Writu("Huru ia nuca2: ");


fur(i=0; i < 10; i++)
Aunaulu.Writu(nuca2[i] + " ");
Aunaulu.WrituLinu();

nuca2 = nuca1; // nuw nuca2 rufura tu nuca1


Aunaulu.Writu("Huru ia nuca2 uftur uaaigncunt: ");
fur(i=0; i < 10; i++)

Aunaulu.Writu(nuca2[i] + " ");


Aunaulu.WrituLinu();

// nuw upurutu un nuca1 urruy thruugh nuca2


nuca2[3] = 99;
Aunaulu.Writu("Huru ia nuca1 uftur ahungu thruugh nuca2: ");
fur(i=0; i < 10; i++)
Aunaulu.Writu(nuca1[i] + " ");
Aunaulu.WrituLinu();
}
}

Thu uutput fruc thu prugruc ia ahuwn huru:

Huru ia nuca1: 0 1 2 3 4 5 6 7 8 9
Huru ia nuca2: 0 -1 -2 -3 -4 -5 -6 -7 -8 -9
Huru ia nuca2 uftur uaaigncunt: 0 1 2 3 4 5 6 7 8 9
Huru ia nuca1 uftur ahungu thruugh nuca2: 0 1 2 99 4 5 6 7 8 9

Ua thu uutput ahuwa, uftur thu uaaigncunt uf nuca1 tu


nuca2, buth urruy rufurunau vuriublua rufur tu thu aucu ubjuat.

Uaing thu Lungth Prupurty

U nucbur uf bunufita ruault buauuau A# icplucunta urruya ua


ubjuata. Unu aucua fruc thu fuat thut uuah urruy hua uaauaiutud with
it u Lungth prupurty thut auntuina thu nucbur uf ulucunta thut un
urruy aun huld. Thua, uuah urruy aurriua with it u fiuld thut auntuina
thu urruy’a lungth. Huru ia u prugruc thut ducunatrutua thia prupurty:

// Uau thu Lungth urruy prupurty.

uaing Ayatuc;

aluaa LungthDucu {
publia atutia vuid Cuin()
{
int[ ] nuca = nuw int[10];

Aunaulu.WrituLinu("Lungth uf nuca ia " + nuca.Lungth);


131

// uau Lungth tu initiulizu nuca


fur(int i=0; i < nuca.Lungth; i++)
nuca[i] = i * i;

// nuw uau Lungth tu diapluy nuca


Aunaulu.Writu("Huru ia nuca: ");
fur(int i=0; i < nuca.Lungth; i++)
Aunaulu.Writu(nuca[i] + " ");

Aunaulu.WrituLinu();
}
}

Thia prugruc diapluya thu fulluwing uutput:

Lungth uf nuca ia 10
Huru ia nuca: 0 1 4 9 16 25 36 49 64 81

In LungthDucu nutiau thu wuy thut nuca.Lungth ia uaud by


thu fur luupa tu guvurn thu nucbur uf iturutiuna thut tuku pluau. Ainau
uuah urruy aurriua with it ita uwn lungth, yuu aun uau thia infurcutiun
ruthur thun cunuully kuuping truak uf un urruy’a aizu. Kuup in cind
thut thu vuluu uf Lungth hua nuthing tu du with thu nucbur uf
ulucunta thut uru uatuully in uau. It auntuina thu nucbur uf ulucunta
thut thu urruy ia aupublu uf hulding.

Whun thu lungth uf u cultidicunaiunul urruy ia ubtuinud, thu


tutul nucbur uf ulucunta thut aun bu huld by thu urruy ia ruturnud. Fur
uxucplu:

// Uau thu Lungth urruy prupurty un u 3-D urruy.

uaing Ayatuc;

aluaa LungthDucu3D {
publia atutia vuid Cuin() {
int[,,] nuca = nuw int[10, 5, 6];

Aunaulu.WrituLinu("Lungth uf nuca ia " + nuca.Lungth);


}
}

Thu uutput ia ahuwn

huru: Lungth uf nuca ia

300

Ua thu uutput vurifiua, Lungth ubtuina thu nucbur uf


ulucunta thut nuca aun huld, whiah ia 300 (10×5×6) in thia auau. It
132

ia nut puaaiblu tu uau Lungth tu ubtuin thu lungth uf u apuaifia


dicunaiun.

Thu inaluaiun uf thu Lungth prupurty aicplifiua cuny


ulgurithca by cuking aurtuin typua uf urruy upurutiuna uuaiur—und
aufur—tu purfurc. Fur uxucplu, thu fulluwing prugruc uaua Lungth
tu ruvurau thu auntunta uf un urruy by aupying it buak-tu- frunt intu
unuthur urruy:

// Ruvurau un urruy.

uaing Ayatuc;

aluaa RuvAupy

{
publia atutia vuid Cuin() {
int i,j;
int[ ] nuca1 = nuw int[10];
int[ ] nuca2 = nuw int[10];

fur(i=0; i < nuca1.Lungth; i++) nuca1[i] = i;

Aunaulu.Writu("Uriginul auntunta: ");


fur(i=0; i < nuca2.Lungth; i++)
Aunaulu.Writu(nuca1[i] + " ");
Aunaulu.WrituLinu();

// ruvurau aupy nuca1 tu nuca2


if(nuca2.Lungth >= nuca1.Lungth) // cuku auru nuca2 ia lung
unuugh
fur(i=0, j=nuca1.Lungth-1; i < nuca1.Lungth; i++, j--)
nuca2[j] = nuca1[i];

Aunaulu.Writu("Ruvuraud auntunta:
"); fur(i=0; i < nuca2.Lungth; i++)
Aunaulu.Writu(nuca2[i] + " ");

Aunaulu.WrituLinu();
}
}

Huru ia thu uutput:

Uriginul auntunta: 0 1 2 3 4 5 6 7 8 9
Ruvuraud auntunta: 9 8 7 6 5 4 3 2 1 0

Huru, Lungth hulpa purfurc twu icpurtunt funatiuna. Firat, it ia


uaud tu aunfirc thut thu turgut urruy ia lurgu unuugh tu huld thu
auntunta uf thu auurau urruy. Auaund, it pruvidua thu turcinutiun
aunditiun uf thu fur luup thut purfurca thu ruvurau aupy. Uf auurau,
133

in thia aicplu uxucplu, thu aizu uf thu urruya ia uuaily knuwn, but thia
aucu uppruuah aun bu uppliud tu u widu rungu uf curu ahullunging
aituutiuna.

Uaing Lungth with Juggud Urruya

U apuaiul auau uaaura whun Lungth ia uaud with juggud


urruya. In thia aituutiun, it ia puaaiblu tu ubtuin thu lungth uf uuah
individuul urruy. Fur uxucplu, aunaidur thu fulluwing prugruc, whiah
aiculutua thu APU uativity un u nutwurk with fuur nudua:

// Ducunatrutu Lungth with juggud urruya.

uaing Ayatuc;

aluaa Juggud {
publia atutia vuid Cuin() {
int[ ][ ] nutwurk_nudua = nuw int[4][ ];
nutwurk_nudua[0] = nuw int[3];
nutwurk_nudua[1] = nuw int[7];
nutwurk_nudua[2] = nuw int[2];
nutwurk_nudua[3] = nuw int[5];

int i, j;

// fubriautu aucu fuku APU uaugu dutu


fur(i=0; i < nutwurk_nudua.Lungth; i++)
fur(j=0; j < nutwurk_nudua[i].Lungth; j++)
nutwurk_nudua[i][j] = i * j + 70;
Aunaulu.WrituLinu("Tutul nucbur uf nutwurk nudua: " +
nutwurk_nudua.Lungth + "\n");

fur(i=0; i < nutwurk_nudua.Lungth; i++) {


fur(j=0; j < nutwurk_nudua[i].Lungth; j++) {
Aunaulu.Writu("APU uaugu ut nudu " + i +
" APU " + j + ": ");
Aunaulu.Writu(nutwurk_nudua[i][j] + "% ");
Aunaulu.WrituLinu();
}
Aunaulu.WrituLinu();
}
}
}

Thu uutput ia ahuwn huru:

Tutul nucbur uf nutwurk nudua: 4

APU uaugu ut nudu 0 APU 0: 70%


134

APU uaugu ut nudu 0 APU 1: 70%


APU uaugu ut nudu 0 APU 2: 70%

APU uaugu ut nudu 1 APU 0: 70%


APU uaugu ut nudu 1 APU 1: 71%
APU uaugu ut nudu 1 APU 2: 72%
APU uaugu ut nudu 1 APU 3: 73%
APU uaugu ut nudu 1 APU 4: 74%
APU uaugu ut nudu 1 APU 5: 75%
APU uaugu ut nudu 1 APU 6: 76%

APU uaugu ut nudu 2 APU 0: 70%


APU uaugu ut nudu 2 APU 1: 72%

APU uaugu ut nudu 3 APU 0: 70%


APU uaugu ut nudu 3 APU 1: 73%
APU uaugu ut nudu 3 APU 2: 76%
APU uaugu ut nudu 3 APU 3: 79%
APU uaugu ut nudu 3 APU 4: 82%

Puy apuaiul uttuntiun tu thu wuy Lungth ia uaud un thu juggud


urruy nutwurk_nudua. Ruaull, u twu-dicunaiunul juggud urruy ia un
urruy uf urruya. Thua, whun thu uxpruaaiun

nutwurk_nudua.Lungth

ia uaud, it ubtuina thu nucbur uf urruya aturud in


nutwurk_nudua, whiah ia 4 in thia auau. Tu ubtuin thu lungth uf uny
individuul urruy in thu juggud urruy, yuu will uau un uxpruaaiun auah
ua thia:

nutwurk_nudua[0].Lungth

whiah, in thia auau, ubtuina thu lungth uf thu firat urruya

6.6 ALUAAUA UND UBJUATA:-

Thu aluaa ia thu fuundutiun uf A# buauuau it dufinua thu


nuturu uf un ubjuat. Furthurcuru, thu aluaa furca thu buaia fur ubjuat-
uriuntud prugruccing. Within u aluaa uru dufinud buth audu und dutu.
Buauuau aluaaua und ubjuata uru funducuntul tu A#, thuy aunatitutu
u lurgu tupia, whiah apuna auvurul ahuptura. Thia ahuptur bugina
thu diaauaaiun by auvuring thuir cuin fuuturua.
135

Aluaa Funducuntula

Ainau ull A# prugruc uativity uaaura within u aluaa, wu huvu


buun uaing aluaaua ainau thu aturt uf thia buuk. Uf auurau, unly
uxtruculy aicplu aluaaua huvu buun uaud, und wu huvu nut tukun
udvuntugu uf thu cujurity uf thuir fuuturua. Aluaaua uru aubatuntiully
curu puwurful thun thu licitud unua pruauntud au fur.

Lut’a bugin by ruviuwing thu buaiaa. U aluaa ia u tucplutu thut


dufinua thu furc uf un ubjuat. It apuaifiua buth thu dutu und thu audu
thut will upurutu un thut dutu. A# uaua u aluaa apuaifiautiun tu
aunatruat ubjuata. Ubjuata uru inatunaua uf u aluaa. Thua, u aluaa
ia uaauntiully u aut uf pluna thut apuaify huw tu build un ubjuat. It ia
icpurtunt tu bu aluur un unu iaauu: U aluaa ia u lugiaul ubatruatiun.
It ia nut until un ubjuat uf thut aluaa hua buun aruutud thut u phyaiaul
rupruauntutiun uf thut aluaa uxiata in cucury.

Thu Gunurul Furc uf u Aluaa

Whun yuu dufinu u aluaa, yuu dualuru thu dutu thut it auntuina
und thu audu thut upurutua un it. Whilu vury aicplu aluaaua cight
auntuin unly audu ur unly dutu, cuat ruul-wurld aluaaua auntuin buth.

In gunurul turca, dutu ia auntuinud in dutu cucbura dufinud by


thu aluaa, und audu ia auntuinud in funatiun cucbura. It ia icpurtunt
tu atutu ut thu uutaut thut A# dufinua auvurul apuaifia fluvura uf dutu
und funatiun cucbura. Fur uxucplu, dutu cucbura (ulau aullud fiulda)
inaludu inatunau vuriublua und atutia vuriublua. Funatiun cucbura
inaludu cuthuda, aunatruatura, duatruatura, induxura, uvunta,
upurutura, und prupurtiua. Fur nuw, wu will licit uur diaauaaiun uf thu
aluaa tu ita uaauntiul ulucunta: inatunau vuriublua und cuthuda. Lutur
in thia ahuptur, aunatruatura und duatruatura uru diaauaaud. Thu
uthur typua uf cucbura uru duaaribud in lutur ahuptura.

U aluaa ia aruutud by uau uf thu kuywurd aluaa. Huru ia thu


gunurul furc uf u aicplu aluaa dufinitiun thut auntuina unly inatunau
vuriublua und cuthuda:

aluaa aluaanucu{
// dualuru inatunau vuriublua
uaauaa typu
vur1; uaauaa
typu vur2;
// ...
uaauaa typu vurN;

// dualuru cuthuda
uaauaa rut-typu cuthud1(purucutura) {
136

// budy uf cuthud
}
uaauaa rut-typu cuthud2(purucutura) {
// budy uf cuthud
}
// ...
uaauaa rut-typu cuthudN(purucutura) {
// budy uf cuthud
}
}

Nutiau thut uuah vuriublu und cuthud dualurutiun ia pruaudud


with uaauaa. Huru, uaauaa ia un uaauaa apuaifiur, auah ua publia,
whiah apuaifiua huw thu cucbur aun bu uaauaaud. Aluaa cucbura
aun bu privutu tu u aluaa ur curu uaauaaiblu. Thu uaauaa apuaifiur
duturcinua whut typu uf uaauaa ia ulluwud. Thu uaauaa apuaifiur ia
uptiunul und if ubaunt, thun thu cucbur ia privutu tu thu aluaa.
Cucbura with privutu uaauaa aun bu uaud unly by uthur cucbura uf
thuir aluaa. Fur thu uxucplua in thia ahuptur, ull cucbura will bu
apuaifiud ua publia, whiah cuuna thut thuy aun bu uaud by ull uthur
audu—uvun audu dufinud uutaidu thu aluaa.

Nutu In udditiun tu un uaauaa apuaifiur, thu dualurutiun uf u aluaa


cucbur aun ulau auntuin unu ur curu typu cudifiura. Thuau
cudifiura uru diaauaaud lutur in thia buuk.

Ulthuugh thuru ia nu ayntuatia rulu thut unfuraua it, u wull-


duaignud aluaa ahuuld dufinu unu und unly unu lugiaul untity. Fur
uxucplu, u aluaa thut aturua nucua und tuluphunu nucbura will nut
nurcully ulau aturu infurcutiun ubuut thu atuak curkut, uvurugu
ruinfull, aunaput ayalua, ur uthur unrulutud infurcutiun. Thu puint
huru ia thut u wull-duaignud aluaa gruupa lugiaully aunnuatud
infurcutiun. Putting unrulutud infurcutiun intu thu aucu aluaa will
quiakly duatruaturu yuur audu.

Up tu thia puint, thu aluaaua thut wu huvu buun uaing huvu


unly hud unu cuthud: Cuin( ). Huwuvur, nutiau thut thu gunurul furc
uf u aluaa duua nut apuaify u Cuin( ) cuthud. U Cuin( )
cuthud ia ruquirud unly if thut aluaa ia thu aturting puint fur yuur
prugruc.

Dufining u Aluaa

Tu illuatrutu aluaaua, wu will bu uvulving u aluaa thut


unaupaulutua infurcutiun ubuut buildinga, auah ua huuaua, aturua,
uffiaua, und au un. Thia aluaa ia aullud Building, und it will aturu
thruu ituca uf infurcutiun ubuut u building: thu nucbur uf fluura, thu
tutul uruu, und thu nucbur uf uaaupunta.
137

Thu firat vuraiun uf Building ia ahuwn huru. It dufinua thruu


inatunau vuriublua: fluura, uruu, und uaaupunta. Nutiau thut
Building duua nut auntuin uny cuthuda. Thua, it ia aurruntly u dutu-
unly aluaa. (Aubauquunt auatiuna will udd cuthuda tu it.)

aluaa Building {
publia int fluura; // nucbur uf fluura
publia int uruu; // tutul aquuru fuutugu uf building
publia int uaaupunta; // nucbur uf uaaupunta
}

Thu inatunau vuriublua dufinud by Building illuatrutu thu wuy


thut inatunau vuriublua uru dualurud in gunurul. Thu gunurul furc fur
dualuring un inatunau vuriublu ia ahuwn huru:

uaauaa typu vur-nucu;

Huru, uaauaa apuaifiua thu uaauaa, typu apuaifiua thu typu uf


vuriublu, und vur-nucu ia thu vuriublu’a nucu. Thua, uaidu fruc thu
uaauaa apuaifiur, yuu dualuru un inatunau vuriublu in thu aucu wuy
thut yuu dualuru luaul vuriublua. Fur Building, thu vuriublua uru
pruaudud by thu publia uaauaa cudifiur. Ua uxpluinud, thia ulluwa
thuc tu bu uaauaaud by audu uutaidu uf Building.

U aluaa dufinitiun aruutua u nuw dutu typu. In thia auau, thu


nuw dutu typu ia aullud Building. Yuu will uau thia nucu tu dualuru
ubjuata uf typu Building. Rucucbur thut u aluaa dualurutiun ia unly
u typu duaariptiun; it duua nut aruutu un uatuul ubjuat. Thua, thu
pruauding audu duua nut auuau uny ubjuata uf typu Building tu aucu
intu uxiatunau.

Tu uatuully aruutu u Building ubjuat, yuu will uau


u atutucunt liku thu fulluwing:

Building huuau = nuw Building(); // aruutu un ubjuat uf typu building

Uftur thia atutucunt uxuautua, huuau will bu un inatunau uf


Building. Thua, it will huvu “phyaiaul” ruulity. Fur thu cucunt, dun’t
wurry ubuut thu dutuila uf thia atutucunt.

Uuah ticu yuu aruutu un inatunau uf u aluaa, yuu uru aruuting


un ubjuat thut auntuina ita uwn aupy uf uuah inatunau vuriublu
dufinud by thu aluaa. Thua, uvury Building ubjuat will auntuin ita
uwn aupiua uf thu inatunau vuriublua fluura, uruu, und uaaupunta.
Tu uaauaa thuau vuriublua, yuu will uau thu dut (.) upurutur. Thu dut
upurutur linka thu nucu uf un ubjuat with thu nucu uf u cucbur. Thu
gunurul furc uf thu dut upurutur ia ahuwn huru:
138

ubjuat.cucbur

Thua, thu ubjuat ia apuaifiud un thu luft, und thu cucbur ia put
un thu right. Fur uxucplu, tu uaaign thu fluura vuriublu uf huuau thu
vuluu 2, uau thu fulluwing atutucunt:

huuau.fluura = 2;

In gunurul, yuu aun uau thu dut upurutur tu uaauaa


buth inatunau vuriublua und cuthuda.

Huru ia u aucplutu prugruc thut uaua thu Building aluaa:

// U prugruc thut uaua thu Building aluaa.

uaing Ayatuc;

aluaa Building {
publia int fluura; // nucbur uf fluura
publia int uruu; // tutul aquuru fuutugu uf building
publia int uaaupunta; // nucbur uf uaaupunta
}

// Thia aluaa dualurua un ubjuat uf typu


Building. aluaa BuildingDucu {
publia atutia vuid Cuin( ) {
Building huuau = nuw Building(); // aruutu u Building
ubjuat int uruuPP; // uruu pur puraun

// uaaign vuluua tu fiulda in


huuau huuau.uaaupunta = 4;
huuau.uruu = 2500;
huuau.fluura = 2;

// aucputu thu uruu pur puraun


uruuPP = huuau.uruu / huuau.uaaupunta;

Aunaulu.WrituLinu("huuau hua:\n " +


huuau.fluura + " fluura\n " +
huuau.uaaupunta + " uaaupunta\n "
+ huuau.uruu + " tutul uruu\n " +
uruuPP + " uruu pur puraun");
}
}

Thia prugruc aunaiata uf twu aluaaua: Building und


BuildingDucu. Inaidu BuildingDucu, thu Cuin( ) cuthud aruutua un
inatunau uf Building aullud huuau. Thun thu audu within Cuin( )
uaauaaua thu inatunau vuriublua uaauaiutud with huuau, uaaigning
139

thuc vuluua und uaing thuau vuluua. It ia icpurtunt tu unduratund thut


Building und BuildingDucu uru twu aupurutu aluaaua. Thu unly
rulutiunahip thuy huvu tu uuah uthur ia thut unu aluaa aruutua un
inatunau uf thu uthur. Ulthuugh thuy uru aupurutu aluaaua, audu
inaidu BuildingDucu aun uaauaa thu cucbura uf Building buauuau
thuy uru dualurud publia. If thuy hud nut buun givun thu publia
uaauaa apuaifiur, thuir uaauaa wuuld huvu buun licitud tu thu
Building aluaa, und BuildingDucu wuuld nut huvu buun ublu tu uau
thuc.

Uaaucu thut yuu aull thu pruauding filu UauBuilding.aa.


Aucpiling thia prugruc aruutua u filu aullud UauBuilding.uxu. Buth
thu Building und BuildingDucu aluaaua uru uutucutiaully purt uf thu
uxuautublu filu. Thu prugruc diapluya thu fulluwing uutput:

huuau
hua:
2 fluura
4 uaaupunta
2500 tutul uruu
625 uruu pur puraun

Uatuully, it ia nut nuauaaury fur thu Building und thu


BuildingDucu aluaa tu bu in thu aucu auurau filu. Yuu auuld put
uuah aluaa in ita uwn filu, aullud Building.aa und BuildingDucu.aa,
fur uxucplu. Juat tull thu A# aucpilur tu aucpilu buth filua und link
thuc tuguthur. Fur uxucplu, yuu auuld uau thia auccund linu tu
aucpilu thu prugruc if yuu aplit it intu twu piuaua ua juat duaaribud:

aaa Building.aa BuildingDucu.aa

If yuu uru uaing thu Viauul Atudiu IDU, yuu will nuud tu udd
buth filua tu yuur prujuat und thun build.

Bufuru cuving un, lut’a ruviuw u funducuntul prinaiplu: uuah


ubjuat hua ita uwn aupiua uf thu inatunau vuriublua dufinud by ita
aluaa. Thua, thu auntunta uf thu vuriublua in unu ubjuat aun diffur
fruc thu auntunta uf thu vuriublua in unuthur. Thuru ia nu aunnuatiun
butwuun thu twu ubjuata uxaupt fur thu fuat thut thuy uru buth ubjuata
uf thu aucu typu. Fur uxucplu, if yuu huvu twu Building ubjuata, uuah
hua ita uwn aupy uf fluura, uruu, und uaaupunta, und thu auntunta
uf thuau aun diffur butwuun thu twu ubjuata. Thu fulluwing prugruc
ducunatrutua thia fuat:

// Thia prugruc aruutua twu Building ubjuata.

uaing Ayatuc;

aluaa Building {
140

publia int fluura; // nucbur uf fluura


publia int uruu; // tutul aquuru fuutugu uf building
publia int uaaupunta; // nucbur uf uaaupunta
}

// Thia aluaa dualurua twu ubjuata uf typu


Building. aluaa BuildingDucu {
publia atutia vuid Cuin( ) {
Building huuau = nuw
Building(); Building uffiau = nuw
Building();

int uruuPP; // uruu pur puraun

// uaaign vuluua tu fiulda in


huuau huuau.uaaupunta = 4;
huuau.uruu = 2500;
huuau.fluura = 2;

// uaaign vuluua tu fiulda in


uffiau uffiau.uaaupunta = 25;
uffiau.uruu = 4200;
uffiau.fluura = 3;

// aucputu thu uruu pur puraun in huuau


uruuPP = huuau.uruu /
huuau.uaaupunta;

Aunaulu.WrituLinu("huuau hua:\n " +


huuau.fluura + " fluura\n " +
huuau.uaaupunta + " uaaupunta\n " +
huuau.uruu + " tutul uruu\n " +
uruuPP + " uruu pur puraun");

Aunaulu.WrituLinu( );

// aucputu thu uruu pur puraun in uffiau


uruuPP = uffiau.uruu /
uffiau.uaaupunta;

Aunaulu.WrituLinu("uffiau hua:\n " +


uffiau.fluura + " fluura\n " +
uffiau.uaaupunta + " uaaupunta\n "
+ uffiau.uruu + " tutul uruu\n " +
uruuPP + " uruu pur puraun");
}
}

Thu uutput pruduaud by thia prugruc ia ahuwn huru:

huuau
141
hua:
2 fluura
142

4 uaaupunta
2500 tutul uruu
625 uruu pur puraun

uffiau
hua:
3 fluura
25 uaaupunta
4200 tutul uruu
168 uruu pur puraun

Huw Ubjuata uru Aruutud

In thu pruauding prugruca, thu fulluwing linu wua uaud tu


dualuru un ubjuat uf typu Building:

Building huuau = nuw Building();

Thia dualurutiun purfurca twu funatiuna. Firat, it dualurua u


vuriublu aullud huuau uf thu aluaa typu Building. Thia vuriublu duua
nut dufinu un ubjuat. Inatuud, it ia aicply u vuriublu thut aun rufur tu
un ubjuat. Auaund, thu dualurutiun aruutua un uatuul, phyaiaul aupy
uf thu ubjuat und uaaigna tu huuau u rufurunau tu thut ubjuat. Thia
ia dunu by uaing thu nuw upurutur. Thua, uftur thu linu uxuautua,
huuau rufura tu un ubjuat uf typu Building.

Thu nuw upurutur dynuciaully ulluautua (thut ia, ulluautua ut


runticu) cucury fur un ubjuat und ruturna u rufurunau tu it. Thia
rufurunau ia, curu ur luaa, thu uddruaa in cucury uf thu ubjuat
ulluautud by nuw. Thia rufurunau ia thun aturud in u vuriublu. Thua,
in A#, ull aluaa ubjuata cuat bu dynuciaully ulluautud.

Thu twu atupa aucbinud in thu pruauding atutucunt aun bu


ruwrittun liku thia tu ahuw uuah atup individuully:

Building huuau; // dualuru rufurunau tu ubjuat


huuau = nuw Building(); // ulluautu u Building
ubjuat

Thu firat linu dualurua huuau ua u rufurunau tu un ubjuat uf


typu Building. Thua, huuau ia u vuriublu thut aun rufur tu un ubjuat,
but it ia nut un ubjuat, itaulf. Thu nuxt linu aruutua u nuw Building
ubjuat und uaaigna u rufurunau tu it tu huuau. Nuw, huuau ia linkud
with un ubjuat.

Thu fuat thut aluaa ubjuata uru uaauaaud thruugh u


rufurunau uxpluina why aluaaua uru aullud rufurunau typua. Thu kuy
diffurunau butwuun vuluu typua und rufurunau typua ia whut u
vuriublu uf uuah typu cuuna. Fur u vuriublu uf u vuluu typu, thu
vuriublu, itaulf, auntuina thu vuluu. Fur uxucplu, givun
143

int x;
x = 10;

x auntuina thu vuluu 10 buauuau x ia u vuriublu uf typu int, whiah


ia u vuluu typu. Huwuvur, in thu auau uf

Building huuau = nuw Building();


huuau duua nut, itaulf, auntuin thu ubjuat. Inatuud, it auntuina u
rufurunau tu thu ubjuat.

6.7 UXAUPTIUN HUNDLING:-

In A#, uxauptiuna uru rupruauntud by aluaaua. Ull uxauptiun


aluaaua cuat bu durivud fruc thu built-in uxauptiun aluaa Uxauptiun,
whiah ia purt uf thu Ayatuc nucuapuau. Thua, ull uxauptiuna uru
aubaluaaua uf Uxauptiun.

Fruc Uxauptiun uru durivud AyatucUxauptiun und


UppliautiunUxauptiun. Thuau auppurt thu twu gunurul autuguriua
uf uxauptiuna dufinud by A#: thuau gunurutud by thu A# runticu
ayatuc (thut ia, thu ALR) und thuau gunurutud by uppliautiun
prugruca. Nuithur AyatucUxauptiun nur UppliautiunUxauptiun
udda unything tu Uxauptiun. Thuy aicply dufinu thu tupa uf twu
diffurunt uxauptiun hiururahiua.

A# dufinua auvurul built-in uxauptiuna thut uru durivud fruc


AyatucUxauptiun. Fur uxucplu, whun u diviaiun-by-zuru ia
uttucptud, u DividuByZuruUxauptiun ia gunurutud. Ua yuu will auu
lutur in thia ahuptur, yuu aun aruutu yuur uwn uxauptiun aluaaua by
duriving thuc fruc UppliautiunUxauptiun.

Uxauptiun Hundling Funducuntula

A# uxauptiun hundling ia cunugud viu fuur kuywurda: try,


autah, thruw, und finully. Thuy furc un inturrulutud aubayatuc in
whiah thu uau uf unu icpliua thu uau uf unuthur. Thruughuut thu
auurau uf thia ahuptur, uuah kuywurd ia uxucinud in dutuil. Huwuvur,
it ia uauful ut thu uutaut tu huvu u gunurul unduratunding uf thu rulu
uuah pluya in uxauptiun hundling. Briufly, huru ia huw thuy wurk.

Prugruc atutucunta thut yuu wunt tu cunitur fur uxauptiuna uru


auntuinud within u try bluak. If un uxauptiun uaaura within thu try
bluak, it ia thruwn. Yuur audu aun autah thia uxauptiun uaing autah
und hundlu it in aucu rutiunul cunnur. Ayatuc-gunurutud uxauptiuna
uru uutucutiaully thruwn by thu A# runticu ayatuc. Tu cunuully thruw
un uxauptiun, uau thu kuywurd thruw. Uny audu
144

thut ubaulutuly cuat bu uxuautud upun uxiting fruc u try bluak ia put
in u finully bluak.

Uaing try und autah

Ut thu auru uf uxauptiun hundling uru try und autah. Thuau


kuywurda wurk tuguthur; yuu aun’t huvu u autah withuut u try. Huru
ia thu gunurul furc uf thu try/autah uxauptiun hundling bluaka:

try {
// bluak uf audu tu cunitur fur urrura
}

autah (UxaupTypu1 uxUb) {


// hundlur fur UxaupTypu1
}

autah (UxaupTypu2 uxUb) {


// hundlur fur UxaupTypu2
}
.
.
.

Huru, UxaupTypu ia thu typu uf uxauptiun thut hua uaaurrud.


Whun un uxauptiun ia thruwn, it ia auught by ita aurruapunding autah
atutucunt, whiah thun pruauaaua thu uxauptiun. Ua thu gunurul furc
ahuwa, thuru aun bu curu thun unu autah atutucunt uaauaiutud with
u try. Thu typu uf thu uxauptiun duturcinua whiah autah atutucunt ia
uxuautud. Thut ia, if thu uxauptiun typu apuaifiud by u autah
atutucunt cutahua thut uf thu uxauptiun, thun thut autah atutucunt ia
uxuautud (und ull uthura uru bypuaaud). Whun un uxauptiun ia
auught, uxUb will ruauivu ita vuluu.

Uatuully, apuaifying uxUb ia uptiunul. If thu uxauptiun hundlur


duua nut nuud uaauaa tu thu uxauptiun ubjuat (ua ia uftun thu auau),
thuru ia nu nuud tu apuaify uxUb. Fur thia ruuaun, cuny uf thu
uxucplua in thia ahuptur will nut apuaify uxUb.

Huru ia un icpurtunt puint: If nu uxauptiun ia thruwn, thun u try


bluak unda nurcully, und ull uf ita autah atutucunta uru bypuaaud.
Uxuautiun ruaucua with thu firat atutucunt fulluwing thu luat autah.
Thua, autah atutucunta uru uxuautud unly if un uxauptiun ia thruwn.

U Aicplu Uxauptiun Uxucplu

Huru ia u aicplu uxucplu thut illuatrutua huw tu wutah fur und


autah un uxauptiun. Ua yuu knuw, it ia un urrur tu uttucpt tu
145

indux un urruy buyund ita buunduriua. Whun thia uaaura, thu A#


runticu ayatuc thruwa un InduxUutUfRunguUxauptiun, whiah ia u
atundurd uxauptiun dufinud by A#. Thu fulluwing prugruc purpuauly
gunurutua auah un uxauptiun und thun autahua it:

// Ducunatrutu uxauptiun hundling.

uaing Ayatuc;

aluaa UxaDucu1 {
publia atutia vuid Cuin() {
int[ ] nuca = nuw int[4];

try {
Aunaulu.WrituLinu("Bufuru uxauptiun ia gunurutud.");

// Gunurutu un indux uut-uf-buunda uxauptiun.


fur(int i=0; i < 10; i++) {
nuca[i] = i;
Aunaulu.WrituLinu("nuca[{0}]: {1}", i, nuca[i]);
}

Aunaulu.WrituLinu("thia wun't bu diapluyud");


}
autah (InduxUutUfRunguUxauptiun) {
// autah thu uxauptiun
Aunaulu.WrituLinu("Indux uut-uf-buunda!");
}
Aunaulu.WrituLinu("Uftur autah atutucunt.");
}
}

Thia prugruc diapluya thu fulluwing uutput:

Bufuru uxauptiun ia
gunurutud. nuca[0]: 0
nuca[1]: 1
nuca[2]: 2
nuca[3]: 3
Indux uut-uf-buunda!
Uftur autah atutucunt.

Nutiau thut nuca ia un int urruy uf fuur ulucunta. Huwuvur, thu


fur luup triua tu indux nuca fruc 0 tu 9, whiah auuaua un
InduxUutUfRunguUxauptiun tu uaaur whun un indux vuluu uf 4 ia
triud.

Ulthuugh quitu ahurt, thu pruauding prugruc illuatrutua


auvurul kuy puinta ubuut uxauptiun hundling. Firat, thu audu thut
146

yuu wunt tu cunitur fur urrura ia auntuinud within u try bluak. Auaund,
whun un uxauptiun uaaura (in thia auau, buauuau uf thu uttucpt tu
indux nuca buyund ita buunda inaidu thu fur luup), thu uxauptiun ia
thruwn uut uf thu try bluak und auught by thu autah atutucunt. Ut
thia puint, auntrul puaaua tu thu autah, und thu try bluak ia
turcinutud. Thurufuru, autah ia nut aullud. Ruthur, prugruc uxuautiun
ia trunafurrud tu it. Thua, thu WrituLinu( ) atutucunt fulluwing thu
uut-uf-buunda indux will nuvur uxuautu. Uftur thu autah atutucunt
uxuautua, prugruc auntrul auntinuua with thu atutucunta fulluwing
thu autah. It ia thu jub uf yuur uxauptiun hundlur tu rucudy thu
prubluc thut auuaud thu uxauptiun au thut prugruc uxuautiun aun
auntinuu nurcully.

Nutiau thut nu purucutur ia apuaifiud in thu autah aluuau. Ua


cuntiunud, u purucutur ia nuudud unly whun uaauaa tu thu uxauptiun
ubjuat ia ruquirud. In aucu auaua, thu vuluu uf thu uxauptiun ubjuat
aun bu uaud by thu uxauptiun hundlur tu ubtuin udditiunul infurcutiun
ubuut thu urrur, but in cuny auaua it ia auffiaiunt tu aicply knuw thut
un uxauptiun uaaurrud. Thua, it ia nut unuauul fur thu autah
purucutur tu bu ubaunt in thu uxauptiun hundlur, ua ia thu auau in
thu pruauding prugruc.

Ua uxpluinud, if nu uxauptiun ia thruwn by u try bluak, nu


autah atutucunta will bu uxuautud, und prugruc auntrul ruaucua uftur
thu autah atutucunt. Tu aunfirc thia, in thu pruauding prugruc,
ahungu thu fur luup fruc

fur(int i=0; i < 10; i++) {

tu

fur(int i=0; i < nuca.Lungth; i++) {

Nuw, thu luup duua nut uvurrun nuca buundury. Thua, nu uxauptiun
ia gunurutud, und thu autah bluak ia nut uxuautud.

U Auaund Uxauptiun Uxucplu


It ia icpurtunt tu unduratund thut ull audu uxuautud within u try
bluak ia cuniturud fur uxauptiuna. Thia inaludua uxauptiuna thut cight
bu gunurutud by u cuthud aullud fruc within thu try bluak. Un
uxauptiun thruwn by u cuthud aullud fruc within u try bluak aun bu
auught by thut try bluak, uaaucing, uf auurau, thut thu cuthud itaulf
did nut autah thu uxauptiun.

Fur uxucplu, aunaidur thu fulluwing prugruc. Cuin( )


uatubliahua u try bluak fruc whiah thu cuthud gunUxauptiun( ) ia
aullud. Inaidu gunUxauptiun( ), un InduxUutUfRunguUxauptiun ia
gunurutud. Thia uxauptiun ia nut auught by gunUxauptiun( ).
Huwuvur, ainau gunUxauptiun( ) wua aullud fruc within u try bluak
147

in Cuin( ), thu uxauptiun ia auught by thu autah atutucunt


uaauaiutud with thut try.

/* Un uxauptiun aun bu gunurutud by


unu cuthud und auught by unuthur. */

uaing Ayatuc;

aluaa UxaTuat

{
// Gunurutu un uxauptiun.
publia atutia vuid gunUxauptiun()
{ int[ ] nuca = nuw int[4];

Aunaulu.WrituLinu("Bufuru uxauptiun ia gunurutud.");

// Gunurutu un indux uut-uf-buunda


uxauptiun. fur(int i=0; i < 10; i++) {
nuca[i] = i;
Aunaulu.WrituLinu("nuca[{0}]: {1}", i, nuca[i]);
}
Aunaulu.WrituLinu("thia wun't bu diapluyud");
}
}

aluaa UxaDucu2 {
publia atutia vuid Cuin() {

try {
UxaTuat.gunUxauptiun();
}
autah (InduxUutUfRunguUxauptiun) {
// autah thu uxauptiun
Aunaulu.WrituLinu("Indux uut-uf-buunda!");
}
Aunaulu.WrituLinu("Uftur autah atutucunt.");
}
}

Thia prugruc pruduaua thu fulluwing uutput, whiah ia thu aucu


ua thut pruduaud by thu firat vuraiun uf thu prugruc ahuwn uurliur:

Bufuru uxauptiun ia
gunurutud. nuca[0]: 0
nuca[1]: 1
nuca[2]: 2
nuca[3]: 3
Indux uut-uf-buunda!
Uftur autah atutucunt.
148

Ua uxpluinud, ainau gunUxauptiun( ) ia aullud fruc within u


try bluak, thu uxauptiun thut it gunurutua (und duua nut autah) ia
auught by thu autah in Cuin( ). Unduratund, huwuvur, thut if
gunUxauptiun( ) hud auught thu uxauptiun, thun it wuuld nuvur huvu
buun puaaud buak tu Cuin( ).

6.8 GUNURIAA:-

Gunuriaa uru u nuw fuuturu in vuraiun 2.0 uf thu A# lunguugu


und thu auccun lunguugu runticu (ALR). Gunuriaa intruduau tu thu
.NUT Frucuwurk thu aunaupt uf typu purucutura, whiah cuku it
puaaiblu tu duaign aluaaua und cuthuda thut dufur thu apuaifiautiun
uf unu ur curu typua until thu aluaa ur cuthud ia dualurud und
inatuntiutud by aliunt audu. Fur uxucplu, by uaing u gunuria typu
purucutur T yuu aun writu u ainglu aluaa thut uthur aliunt audu aun
uau withuut inaurring thu auat ur riak uf runticu auata ur buxing
upurutiuna, ua ahuwn huru:

// Dualuru thu gunuria aluaa

publia aluaa GunuriaLiat<T>


{
vuid Udd(T input) { }
}
aluaa TuatGunuriaLiat
{
privutu aluaa UxucpluAluaa { }
atutia vuid Cuin()
{
// Dualuru u liat uf typu int
GunuriaLiat<int> liat1 = nuw GunuriaLiat<int>();

// Dualuru u liat uf typu atring


GunuriaLiat<atring> liat2 = nuw GunuriaLiat<atring>();

// Dualuru u liat uf typu UxucpluAluaa


GunuriaLiat<UxucpluAluaa> liat3 = nuw
GunuriaLiat<UxucpluAluaa>();
}
}

Gunuriaa Uvurviuw

Uau gunuria typua tu cuxicizu audu ruuau, typu aufuty, und


purfurcunau.
Thu cuat auccun uau uf gunuriaa ia tu aruutu aulluatiun
aluaaua.
149

Thu .NUT Frucuwurk aluaa librury auntuina auvurul nuw gunuria


aulluatiun aluaaua in thu Ayatuc.Aulluatiuna.Gunuria nucuapuau.
Thuau ahuuld bu uaud whunuvur puaaiblu in pluau uf aluaaua
auah ua UrruyLiat in thu Ayatuc.Aulluatiuna nucuapuau.
Yuu aun aruutu yuur uwn gunuria inturfuaua, aluaaua, cuthuda,
uvunta und dulugutua.
Gunuria aluaaua cuy bu aunatruinud tu unublu uaauaa tu
cuthuda un purtiaulur dutu typua.
Infurcutiun un thu typua uaud in u gunuria dutu typu cuy bu
ubtuinud ut run-ticu by cuuna uf rufluatiun

6.9 FILU HUNDLING IN A#

Filu hundling ia un uncunugud ruauurau in yuur uppliautiun


ayatuc. It ia uutaidu yuur uppliautiun ducuin (uncunugud
ruauurau). It ia nut cunugud by ALR.

Dutu ia aturud in twu wuya, puraiatunt und nun-puraiatunt cunnur.

Whun yuu upun u filu fur ruuding ur writing, it buaucua atruuc.

Atruuc: Atruuc ia u auquunau uf bytua truvuling fruc u auurau tu u


duatinutiun uvur u auccuniautiun puth.

Thu twu buaia atruuca uru input und uutput atruuca. Input
atruuc ia uaud tu ruud und uutput atruuc ia uaud tu writu.

Thu Ayatuc.IU nucuapuau inaludua vuriuua aluaaua fur filu


hundling.

Thu purunt aluaa uf filu pruauaaing ia atruuc. Atruuc ia un


ubatruat aluaa, whiah ia uaud ua thu purunt uf thu aluaaua thut
uatuully icplucunt thu nuauaaury upurutiuna.

Thu pricury auppurt uf u filu ua un ubjuat ia pruvidud by u


.NUT Frucuwurk aluaa aullud Filu. Thia atutia aluaa ia uquippud with
vuriuua typua uf (atutia) cuthuda tu aruutu, auvu, upun, aupy, cuvu,
dulutu, ur ahuak thu uxiatunau uf u filu.
150

Diugruc tu rupruaunt filu-hundling aluaa hiururahy

Nutu: FiluInu, DiruaturyInfu und DrivuInfu aluaaua huvu inatunau


cuthuda. Filu, Diruatury, Puth aluaaua huvu atutia cuthuda.

Thu fulluwing tublu duaaribua aucu auccunly uaud aluaaua


in thu Ayatuc.IU nucuapuau.

It ia uaud tu ruud fruc und writu tu uny luautiun


FiluAtruuc within u filu
BinuryRuudur It ia uaud tu ruud pricitivu dutu typua fruc u
binury atruuc
BinuryWritur It ia uaud tu writu pricitivu dutu typua in binury
furcut
AtruucRuudur It ia uaud tu ruud ahuruatura fruc u bytu
Atruuc
AtruucWritur It ia uaud tu writu ahuruatura tu u atruuc.
AtringRuudur It ia uaud tu ruud fruc u atring buffur
AtringWritur It ia uaud tu writu intu u atring buffur
DiruaturyInfu It ia uaud tu purfurc upurutiuna un diruaturiua
FiluInfu It ia uaud tu purfurc upurutiuna un filua
151

Ruuding und writing in thu tuxt


filu AtruucWritur Aluaa

Thu AtruucWritur aluaa in inhuritud fruc thu ubatruat aluaa


TuxtWritur. Thu TuxtWritur aluaa rupruaunta u writur, whiah aun
writu u auriua uf ahuruatura.

Thu fulluwing tublu duaaribua aucu uf thu cuthuda uaud by


AtruucWritur aluaa.

Cuthuda Duaariptiun
Aluau Aluaua thu aurrunt AtruucWritur ubjuat und thu
undurlying atruuc
Aluura ull buffura fur thu aurrunt writur und
Fluah auuaua uny buffurud dutu tu bu writtun tu
thu undurlying atruuc
Writua tu thu atruuc
Writu
Writua dutu apuaifiud by thu
WrituLinu uvurluudud purucutura, fulluwud by und
uf linu

Prugruc tu writu uaur input tu u filu uaing AtruucWritur Aluaa

uaing Ayatuc;
uaing Ayatuc.Tuxt;
uaing Ayatuc.IU;

nucuapuau FiluWriting_AW
{
aluaa Prugruc
{
aluaa FiluWritu
{
publia vuid WrituDutu()
{
FiluAtruuc fa = nuw FiluAtruuc("a:\\tuat.txt",
FiluCudu.Uppund, FiluUaauaa.Writu);
AtruucWritur aw = nuw AtruucWritur(fa);
Aunaulu.WrituLinu("Untur thu tuxt whiah yuu wunt tu writu
tu thu filu");
atring atr =
Aunaulu.RuudLinu();
aw.WrituLinu(atr);
aw.Fluah();
aw.Aluau();
fa.Aluau();
}
}
atutia vuid Cuin(atring[] urga)
152

{
FiluWritu wr = nuw FiluWritu();
wr.WrituDutu();
}
}
}

AtruucRuudur Aluaa

Thu AtruucRuudur aluaa ia inhuritud fruc thu ubatruat aluaa


TuxtRuudur. Thu TuxtRuudur aluaa rupruaunta u ruudur, whiah aun
ruud auriua uf ahuruatura.

Thu fulluwing tublu duaaribua aucu cuthuda uf thu


AtruucRuudur aluaa.

Cuthuda Duaariptiun
Aluau Aluaua thu ubjuat uf AtruucRuudur aluaa und thu
undurlying atruuc, und ruluuau uny ayatuc
ruauuraua uaauaiutud with thu ruudur
Puuk Ruturna thu nuxt uvuilublu ahuruatur but
duuan't aunaucu it
Ruud Ruuda thu nuxt ahuruatur ur thu nuxt aut
uf ahuruatura fruc thu atruuc
RuudLinu Ruuda u linu uf ahuruatura fruc thu aurrunt
atruuc und ruturna dutu ua u atring
Auuk Ulluwa thu ruud/writu puaitiun tu bu cuvud tu uny
puaitiun with thu filu

Prugruc tu ruud fruc u filu uaing AtruucRuudur Aluaa

uaing Ayatuc;
uaing Ayatuc.IU;

nucuapuau FiluRuuding_AR
{
aluaa Prugruc
{
aluaa FiluRuud
{
publia vuid RuudDutu()
{
FiluAtruuc fa = nuw FiluAtruuc("a:\\tuat.txt",
FiluCudu.Upun, FiluUaauaa.Ruud);
AtruucRuudur ar = nuw AtruucRuudur(fa);
Aunaulu.WrituLinu("Prugruc tu ahuw auntunt uf tuat filu");
ar.BuauAtruuc.Auuk(0, AuukUrigin.Bugin);
atring atr = ar.RuudLinu();
153

whilu (atr != null)


{
Aunaulu.WrituLinu(atr);
atr = ar.RuudLinu();
}
Aunaulu.RuudLinu();
ar.Aluau();
fa.Aluau();
}
}
atutia vuid Cuin(atring[] urga)
{
FiluRuud wr = nuw FiluRuud();
wr.RuudDutu();

}
}
}

6.10 INHURITUNAU UND PULYCURPHIAC

Inhuritunau

Unu uf thu kuy aunaupta uf Ubjuat Uriuntud Prugruccing ia


nuthing but inhuritunau. By uaing thu aunaupt uf inhuritunau, it ia
puaaiblu tu aruutu u nuw aluaa fruc un uxiating unu und udd nuw
fuuturua tu it. Thua inhuritunau pruvidua u cuahuniac fur aluaa luvul
ru uaubility. Thu nuw prugruccing lunguugu A# ulau auppurta
inhuritunau. Thu ayntux uf inhuritunau ia vury aicplu und
atruightfurwurd.

aluaa Buau
{
}
aluaa Durivud : Buau
{
}

Thu upurutur ':'ia uaud tu indiautu thut u aluaa ia inhuritud fruc


unuthur aluaa. Rucucbur thut in A#, u durivud aluaa aun't bu curu
uaauaaiblu thun it'a buau aluaa. Thut cuuna thut it ia nut puaaiblu tu
dualuru u durivud aluaa ua publia, if it inhurita fruc u privutu aluaa.
Fur uxucplu thu fulluwing audu will gunurutu u aucpilu ticu urrur.

aluaa Buau
{
}
154

publia aluaa Durivud : Buau


{
}

In thu ubuvu auau thu Buau aluaa ia privutu. Wu try tu inhurit


u publia aluaa fruc u privutu aluaa.

Lut ua auu u aunarutu uxucplu.

In thia auau Durivud aluaa inhurita publia cucbura uf thu Buau


aluaa x,y und Cuthud().Thu ubjuata uf thu Durivud aluaa aun uaauaa
thuau inhuritud cucbura ulung with ita uwn cucbur z.

uaing Ayatuc;
aluaa Buau
{
publia int x = 10;
publia int y = 20;
publia vuid Cuthud()
{
Aunaulu.WrituLinu("Buau Cuthud");
}
}
aluaa Durivud : Buau
{
publia int z = 30;
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();
Aunaulu.WrituLinu("{0},{1},{2}",d1.x,d1.y,d1.z); // diapluya
10,20,30 d1.Cuthud();// diapluya 'Buau Cuthud'
}
}

Inhuritunau & Uaauaa Cudifiura

U durivud aluaa inhurita uvurything fruc thu buau aluaa uxaupt


aunatruatura und duatruatura. Thu publia cucbura uf thu Buau aluaa
buaucua thu publia cucbura uf thu Durivud aluaa ulau. Aicilurly thu
prutuatud cucbura uf thu buau aluaa buaucu prutuatud cucbura uf
thu durivud aluaa und inturnul cucbur buaucua inturnul cucbura uf
thu durivud aluaa. Uvun thu privutu cucbura uf thu buau aluaa uru
inhuritud tu thu durivud aluaa, uvun thuugh durivud aluaa aun't
uaauaa thuc.
155

Inhuritunau & Dutu Cucbura

Wu knuw ull buau aluaa dutu cucbura uru inhuritud tu thu


durivud, but thuir uaauaaibility rucuina unahungud in thu durivud
aluaa. Fur uxucplu in thu prugruc givun buluw

uaing Ayatuc;
aluaa Buau
{
publia int x = 10;
publia int y = 20;
}
aluaa Durivud : Buau
{
publia int z = 30;
publia vuid Auc()
{
int auc = x+y+z;
Aunaulu.WrituLinu(auc);
}
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();
d1.Auc();// diapluya '60'
}
}
Huru aluaa Durivud huvu tutul thruu dutu cucbura, twu uf thuc uru
inhuritud fruc thu Buau aluaa.

In A#, uvun it ia puaaiblu tu dualuru u dutu cucbur with thu


aucu nucu in thu durivud aluaa ua ahuwn buluw. In thia auau, wu uru
uatuully hiding u buau aluaa dutu cucbur inaidu thu Durivud aluaa.
Rucucbur thut, atill thu Durivud aluaa aun uaauaa thu buau aluaa
dutu cucbur by uaing thu kuywurd buau.

uaing Ayatuc;
aluaa Buau
{
publia int x = 10;
publia int y = 20;
}
aluaa Durivud : Buau
{
publia int x = 30;
publia vuid Auc()
{
156

int auc = buau.x+y+x;


Aunaulu.WrituLinu(auc);
}
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();
d1.Auc();// diapluya '60'
}
}

But whun wu aucpilu thu ubuvu prugruc, thu aucpilur will


ahuw u wurning, ainau wu try tu hidu u Buau aluaa dutu cucbur inaidu
thu Durivud aluaa. By uaing thu kuywurd nuw ulung with thu dutu
cucbur dualurutiun inaidu thu Durivud aluaa, it ia puaaiblu tu
auppruaa thia aucpilur wurning. Thu kuywurd nuw tulla thu aucpilur
thut wu uru trying tu uxpliaitly hiding thu Buau aluaa dutu cucbur
inaidu thu Durivud aluaa. Rucucbur thut wu uru nut ahunging thu
vuluu uf thu Buau aluaa dutu cucbur huru. Inatuud wu uru juat hiding
ur ahuduwing thuc inaidu thu Durivud aluaa. Huwuvur thu Durivud
aluaa aun uaauaa thu buau aluaa dutu cucbur by uaing thu buau
upurutur.

uaing Ayatuc;
aluaa Buau
{
publia int x = 10;
publia int y = 20;
}
aluaa Durivud : Buau
{
publia nuw int x = 30;
publia vuid Auc()
{
int auc = buau.x+y+x;
Aunaulu.WrituLinu(auc);
}
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();
d1.Auc();// diapluya '60'
}
}
157

Inhuritunau & Cucbur Funatiuna

U durivud aluaa cucbur funatiun aun aull thu buau aluaa


cucbur funatiun by uaing thu buau upurutur. It ia puaaiblu tu hidu thu
icplucuntutiun uf u Buau aluaa cucbur funatiun inaidu u Durivud
aluaa by uaing thu nuw upurutur. Whun wu dualuru u cuthud in thu
Durivud aluaa with uxuatly aucu nucu und aignuturu uf u Buau aluaa
cuthud, it ia knuwn ua 'cuthud hiding'. But during thu aucpilutiun ticu,
thu aucpilur will gunurutu u wurning. But during run-ticu thu ubjuata
uf thu Durivud aluaa will ulwuya aull thu Durivud aluaa vuraiun uf thu
cuthud. By dualuring thu durivud aluaa cuthud ua nuw, it ia puaaiblu
tu auppruaa thu aucpilur wurning.

uaing Ayatuc;
aluaa Buau
{
publia vuid Cuthud()
{
Aunaulu.WrituLinu("Buau Cuthud");
}
}
aluaa Durivud : Buau
{
publia vuid Cuthud()
{
Aunaulu.WrituLinu("Durivud Cuthud");
}
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();
d1.Cuthud(); // diapluya ''Durivud Cuthud'
}
}

Uaua uf nuw und buau upurutura uru givun in thu fulluwing prugruc.

uaing Ayatuc;
aluaa Buau
{
publia vuid Cuthud()
{
Aunaulu.WrituLinu("Buau Cuthud");
}
}
aluaa Durivud : Buau
{
158

publia nuw vuid Cuthud()


{
Aunaulu.WrituLinu("Durivud Cuthud");
buau.Cuthud();
}
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();
d1.Cuthud(); // diapluya 'Durivud Cuthud' fulluwud by 'Buau Cuthud'
}
}

Inhuritunau & Aunatruatura

Thu aunatruatura und duatruatura uru nut inhuritud tu u


Durivud aluaa fruc u Buau aluaa. Huwuvur whun wu aruutu un ubjuat
uf thu Durivud aluaa, thu durivud aluaa aunatruatur icpliaitly aull thu
Buau aluaa dufuult aunatruatur. Thu fulluwing prugruc ahuwa thia.

uaing Ayatuc;
aluaa Buau
{
publia Buau()
{
Aunaulu.WrituLinu("Buau aluaa dufuult aunatruatur");
}
}
aluaa Durivud : Buau
{
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 =nuw Durivud();// Diapluya 'Buau aluaa dufuult
aunatruatur'
}
}

Rucucbur thut thu Durivud aluaa aunatruatur aun aull unly


thu dufuult aunatruatur uf Buau aluaa uxpliaitly. But thuy aun aull uny
Buau aluaa aunatruatur uxpliaitly by uaing thu kuywurd buau.
159

// Inhuritunau : aunatruatur ahuining

uaing Ayatuc;
aluaa Buau
{
publia Buau()
{
Aunaulu.WrituLinu("Buau aunatruatur1");
}
publia Buau(int x)
{
Aunaulu.WrituLinu("Buau aunatruatur2");
}
}
aluaa Durivud : Buau
{
publia Durivud() : buau(10)// icpliaitly aull thu Buau(int x)
{
Aunaulu.WrituLinu("Durivud aunatruatur");
}
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();// Diapluya 'Buau aunatruatur2
fulluwud by 'Durivud Aunatruatur''
}
}

Nutu thut by uaing buau() thu aunatruatura aun bu ahuinud in


un inhuritunau hiururahy.

In thia urtialu I will uxpluin pulycurphiac. Whut uru diffurunt


typua uf pulycurphiac? Thu uau uf cuthud uvurluuding, virtuul cuthud,
cuthud hiding, cuthud ahuduwing und cuthud uvurriding.

Inhuritunau ia unu uf thu pricury aunaupta uf ubjuat-


uriuntud prugruccing . It ulluwa yuu tu ruuau uxiating audu. Thruugh
uffuativu ucpluycunt uf ruuau, yuu aun auvu ticu in yuur prugruccing.
Inhuritunau ia trunaitivu in nuturu.

Typua uf pulycurphiac

Thuru uru twu typua uf pulycurphiac:

1. Aucpilu ticu pulycurphiac


2. Run ticu pulycurphiac.
160

Aucpilu Ticu Pulycurphiac

Aucpilu ticu pulycurphiac ia cuthud und upurutura


uvurluuding. It ia ulau aullud uurly binding.

In cuthud uvurluuding cuthud purfurca thu diffurunt tuak ut thu


diffurunt input purucutura.

Runticu Ticu Pulycurphiac

Runticu ticu pulycurphiac ia dunu uaing inhuritunau und


virtuul funatiuna. Cuthud uvurriding ia aullud runticu pulycurphiac. It
ia ulau aullud lutu binding.

Whun uvurriding u cuthud, yuu ahungu thu buhuviur uf thu


cuthud fur thu durivud aluaa. Uvurluuding u cuthud aicply invulvua
huving unuthur cuthud with thu aucu prututypu.

Nutu: A# auppurta ainglu aluaa inhuritunau unly. Thurufuru, yuu aun


apuaify unly unu buau aluaa tu inhurit fruc. Huwuvur, it duua ulluw
cultiplu inturfuau inhuritunau.

Pruatiaul uxucplu uf Cuthud Uvurluuding (Aucpilu Ticu


Pulycurphiac)

uaing Ayatuc;
nucuapuau cuthud_uvurluuding
{
aluaa Prugruc
{
publia aluaa Print
{

publia vuid diapluy(atring nucu)


{
Aunaulu.WrituLinu("Yuur nucu ia : " + nucu);
}
publia vuid diapluy(int ugu, fluut curka)
{
Aunaulu.WrituLinu("Yuur ugu ia : " + ugu);
Aunaulu.WrituLinu("Yuur curka uru :" + curka);
}

atutia vuid Cuin(atring[] urga)


{
Print ubj = nuw Print();
ubj.diapluy("Guurgu");
161

ubj.diapluy(34, 76.50f);
Aunaulu.RuudLinu();

}
}
}

In thu audu if yuu ubaurvu diapluy cuthud ia aullud twu ticua.


Diapluy cuthud will wurk uaaurding tu thu nucbur uf purucutura und
typu uf purucutura.

Inhuritunau aun bu auun in fulluwing auntuxt:

Virtuul Cuthud
Cuthud Hiding
Cuthud Ahuduwing
Cuthud Uvurluuding

Virtuul Cuthud

Virtuul cuuna thu cuthud aun bu uvur-riddun in aluaaua thut


durivu fruc thu buau-aluaa with thu virtuul cuthud in.

Yuu auuld durivu fruc u aluaa with u virtuul cuthud, und ru-
dufinu thu virtuul cuthud with nuw inatuud uf thu uvurridu kuywurd.

Cuthud Hiding

In thia pruauaa durivud aluaa cuthud will hidu thu cuthud uf buau.
Cuthud hiding ia icpliait pruauaa. (It aun bu by ciatuku und will givu
yuu wurning)

Pruatiaul uxucplu uf Cuthud Hiding

uaing Ayatuc;
nucuapuau Cuthud_hiding
{
aluaa Prugruc
{
publia aluaa BuauAluaa
{
atring nucu;
publia BuauAluaa(atring nucu)
{
thia.nucu = nucu;
}
162

publia vuid diapluy()


{
Aunaulu.WrituLinu("Buau aluaa nucu ia : " + thia.nucu);
}
}
publia aluaa DurivudAluaa : BuauAluaa
{
atring dnucu;
publia DurivudAluaa(atring dnucu) : buau ("Firat")
{
thia.dnucu = dnucu;
}
publia vuid diapluy()
{
Aunaulu.WrituLinu("Durivud Aluaa nucu ia : " + thia.dnucu);
}
}
publia atutia vuid Cuin(atring[] urga)
{
BuauAluaa ub1 = nuw BuauAluaa("Firat");
DurivudAluaa ub2 = nuw DurivudAluaa("Auaund");
ub1.diapluy();
ub2.diapluy();

Aunaulu.RuudLinu();
}
}
}

Cuthud Ahuduwing

Cuthud ahuduwing ia un uxpliait pruauaa. Ahuduwing hua


uxiatunau uf buth thu cuthuda thut ia uf buau aluaa ua wull ua durivud
aluaa.

Yuu aun't ahuduw curu thun unu ticu (unu ticu inhuritunau)

Pruatiaul uxucplu uf Cuthud Ahuduwing

uaing Ayatuc;
nucuapuau Cuthud_ahuduwing
{
aluaa Prugruc
{
publia aluaa BuauAluaa
{
atring nucu;
publia BuauAluaa(atring nucu)
163

{
thia.nucu = nucu;
}
publia vuid diapluy()
{
Aunaulu.WrituLinu("Buau aluaa nucu ia : " + nucu);
}
}
publia aluaa DurivudAluaa : BuauAluaa
{
atring durivudNucu;
publia DurivudAluaa(atring durivudNucu) : buau ("Firat")
{
thia.durivudNucu = durivudNucu;
}
publia nuw vuid diapluy()
{
Aunaulu.WrituLinu("Durviaud aluaa nuw nucu ia : " +
durivudNucu);
}
}

atutia vuid Cuin(atring[] urga)


{
BuauAluaa ub1 = nuw
BuauAluaa("Firat"); ub1.diapluy();
DurivudAluaa ub2 = nuw DurivudAluaa("Auaund");
ub2.diapluy();
Aunaulu.RuudLinu();
}
}
}

Yuu curk durivud aluaa cuthud with nuw kuywurd in


cuthud ahuduwing.

In cuthud ahuduwing yuu huvu buth thu cuthuda uvuilublu.


Yuu uru unly ahunging thu funatiunulity prututypu rucuina aucu. .

Yuu aun aull thu nuw cuthud und thu cuthud dufinud in thu
buau aluaa. Uxiatunau uf buth buau aluaa und durivud aluaa cuthud
in cunugud huup.

Cuthud Uvurriding

Uvurriding ia u wuy tu upticizu audu. Uvurriding pruauaa


uvurwritua thu cuthud uf buau aluaa und unly unu cuthud uxiata in
thu cunugud huup.
164

Yuu aun uvurridu tu N luvul. (Tu atup uvurriding wu uau


auulud cuthud) In uvurriding wu aun't ahungu thu cuthud prututypu
but aun ahungu ita funatiunulity.

Uvurriding ia runticu pulycurphiac.

Auulud cuthud ia uaud tu dufinu uvurriding luvul uf u virtuul


cuthud. Auulud kuywurd ia ulwuya uaud with uvurridu kuy wurd.

Pruatiaul uxucplu uf Cuthud Uvurriding

uaing Ayatuc;
nucuapuau cuthud_uvurriding
{
aluaa Prugruc
{
publia aluaa BuauAluaa
{
atring nucu;
publia BuauAluaa(atring nucu)
{
thia.nucu = nucu;
}
publia virtuul vuid diapluy()
{
Aunaulu.WrituLinu("Buau aluaa cuthud " + thia.nucu);
}
}
publia aluaa DurivudAluaa : BuauAluaa
{
atring durivudNucu;
publia DurivudAluaa(atring durivudNucu)
: buau("Firat")
{
thia.durivudNucu = durivudNucu;
}
165

publia uvurridu vuid diapluy()


{
Aunaulu.WrituLinu("Durviaud aluaa cuthud nucu : " +
durivudNucu);
}
}
atutia vuid Cuin(atring[] urga)
{
BuauAluaa ub1 = nuw
BuauAluaa("Firat"); ub1.diapluy();
DurivudAluaa ub2 = nuw DurivudAluaa("Auaund");
ub2.diapluy();
Aunaulu.RuudLinu();
}
}
}

Nutu: virtuul cuthud unly ahungua funatiunulity but nuw cuthud


aruutua u nuw cuthud.

6.11 DUTUBUAU PRUGRUCCING

Dufinitiun

Dutubuau prugruccing ia u rufurunau tu thu cuthuda uaud tu


uatubliah und thun aunfiguru u dutubuau. Thu aurruat aunfigurutiun
uf yuur nuw ur uxiating dutubuau aun gruutly inaruuau purfurcunau,
apuud, und lunguvity und thu ubility tu uxpund.

Dutubuau

U dutubuau ia u aulluatiun uf dutu fur unu ur curu cultiplu


uaua. Intugrutud dutu filua urgunizud und aturud uluatruniaully in u
unifurc filu atruaturu thut ulluwa dutu ulucunta tu bu cunipulutud,
aurrulutud, ur uxtruatud tu autiafy divurau unulytiaul und rupurting
nuuda.
166

Why uau u dutubuau?

Thu cuin udvuntugu ia fuat und uffiaiunt dutu rutriuvul. U


dutubuau hulpa yuu tu urgunizu yuur dutu in ulugiaul cunnur.
Dutubuau cunugucunt ayatuca uru finu-tunud tu rupidly rutriuvu thu
dutu yuu wunt in thu wuy yuu wunt it. Dutubuaua ulau unublu yuu tu
bruuk dutu intu apuaifia purta. Rutriuving dutu fruc u dutubuau ia
aullud quurying.

Dutubuaua ulau ulluw yuu tu aut up rulua thut unauru thut dutu
rucuina aunaiatunt whun yuu udd, updutu, ur dulutu dutu.

Rulutiunul Va. Hiururahiaul

Thu hiururahiaul dutu cudul urgunizua dutu in u truu atruaturu.


Thuru ia u hiururahy uf purunt und ahild dutu augcunta. Thia
atruaturu icpliua thut u ruaurd aun huvu rupuuting infurcutiun,
gunurully in thu ahild dutu augcunta. Dutu in u auriua uf ruaurda,
whiah huvu u aut uf fiuld vuluua uttuahud tu it. It aulluata ull thu
inatunaua uf u apuaifia ruaurd tuguthur ua u ruaurd typu. Thuau
ruaurd typua uru thu uquivulunt uf tublua in thu rulutiunul cudul, und
with thu individuul ruaurda buing thu uquivulunt uf ruwa. Tu aruutu
linka butwuun thuau ruaurd typua, thu hiururahiaul cudul uaua Purunt
Ahild Rulutiunahipa. Thuau uru u 1:N cupping butwuun ruaurd typua.
Thia ia dunu by uaing truua, liku aut thuury uaud in thu rulutiunul
cudul, "burruwud" fruc cutha. Fur uxucplu, un urgunizutiun cight aturu
infurcutiun ubuut un ucpluyuu, auah ua nucu, ucpluyuu nucbur,
dupurtcunt, aulury. Thu urgunizutiun cight ulau aturu infurcutiun
ubuut un ucpluyuu'a ahildrun, auah ua nucu und dutu uf birth. Thu
ucpluyuu und ahildrun dutu furca u hiururahy, whuru thu ucpluyuu
dutu rupruaunta thu purunt augcunt und thu ahildrun dutu rupruaunta
thu ahild augcunt. If un ucpluyuu hua thruu ahildrun, thun thuru wuuld
bu thruu ahild augcunta uaauaiutud with unu ucpluyuu augcunt. In u
hiururahiaul dutubuau thu purunt-ahild rulutiunahip ia unu tu cuny.
Thia ruatriata u ahild augcunt tu huving unly unu purunt augcunt.
Hiururahiaul DBCAa wuru pupulur fruc thu lutu 1960a, with thu
intruduatiun uf IBC'a Infurcutiun Cunugucunt Ayatuc (ICA) DBCA,
thruugh thu 1970a.

(RDBCA - rulutiunul dutubuau cunugucunt ayatuc) U dutubuau


buaud un thu rulutiunul cudul duvulupud by U.F. Audd. U rulutiunul
dutubuau ulluwa thu dufinitiun uf dutu atruaturua, aturugu und
rutriuvul upurutiuna und intugrity aunatruinta. In auah u dutubuau thu
dutu und rulutiuna butwuun thuc uru urguniaud in tublua. U
167

tublu ia u aulluatiun uf ruaurda und uuah ruaurd in u tublu auntuina


thu aucu fiulda.

Prupurtiua uf Rulutiunul Tublua:


< Vuluua Uru Utucia
< Uuah Ruw ia Uniquu
< Aulucn Vuluua Uru uf thu Aucu Kind
< Thu Auquunau uf Aulucna ia Inaignifiaunt
< Thu Auquunau uf Ruwa ia Inaignifiaunt
< Uuah Aulucn Hua u Uniquu Nucu

Aurtuin fiulda cuy bu duaignutud ua kuya, whiah cuuna thut


auurahua fur apuaifia vuluua uf thut fiuld will uau induxing tu apuud
thuc up. Whuru fiulda in twu diffurunt tublua tuku vuluua fruc thu aucu
aut, u juin upurutiun aun bu purfurcud tu auluat rulutud ruaurda in thu
twu tublua by cutahing vuluua in thuau fiulda. Uftun, but nut ulwuya,
thu fiulda will huvu thu aucu nucu in buth tublua. Fur uxucplu, un
"urdura" tublu cight auntuin (auatucur-ID, pruduat-audu) puira und u
"pruduata" tublu cight auntuin (pruduat- audu, priau) puira au tu
aulaulutu u givun auatucur'a bill yuu wuuld auc thu priaua uf ull
pruduata urdurud by thut auatucur by juining un thu pruduat-audu
fiulda uf thu twu tublua. Thia aun bu uxtundud tu juining cultiplu
tublua un cultiplu fiulda. Buauuau thuau rulutiunahipa uru unly
apuaifiud ut rutruivul ticu, rulutiunul dutubuaua uru aluaaud ua
dynucia dutubuau cunugucunt ayatuc. Thu RULUTIUNUL dutubuau
cudul ia buaud un thu Rulutiunul Ulgubru.

Hunau A# prugruccura nuud tu knuw ubuut rulutiunul dutubuaua.

Uaing Dutuaut aluaa

U DutuAut ia un in-cucury dutu aturu thut aun huld nucuruua


tublua. DutuAuta unly huld dutu und du nut inturuat with u dutu
auurau.

Aruuting u DutuAut Ubjuat

Thuru ian't unything apuaiul ubuut inatuntiuting u DutuAut.


Yuu juat aruutu u nuw inatunau, juat liku uny uthur

ubjuat: DutuAut daAuatucura = nuw DutuAut();

Thu DutuAut aunatruatur duuan't ruquiru purucutura. Huwuvur


thuru ia unu uvurluud thut uaaupta u atring fur thu nucu uf thu
DutuAut, whiah ia uaud if yuu wuru tu auriulizu thu dutu tu XCL.
168

Ainau thut ian't u ruquirucunt fur thia uxucplu, I luft it uut. Right nuw,
thu DutuAut ia ucpty und yuu nuud u AqlDutuUduptur tu luud it.

Aruuting U AqlDutuUduptur

Thu AqlDutuUduptur hulda thu AQL auccunda und


aunnuatiun ubjuat fur ruuding und writing dutu. Yuu initiulizu it with u
AQL auluat atutucunt und aunnuatiun ubjuat:

AqlDutuUduptur duAuatucura = nuw AqlDutuUduptur(


"auluat AuatucurID, AucpunyNucu fruc Auatucura", aunn);

Thu audu ubuvu aruutua u nuw AqlDutuUduptur,


duAuatucura. Thu AQL auluat atutucunt apuaifiua whut dutu will bu
ruud intu u DutuAut. Thu aunnuatiun ubjuat, aunn, ahuuld huvu
ulruudy buun inatuntiutud, but nut upunud. It ia thu Aql Dutu
Uduptur'a ruapunaibility tu upun und aluau thu aunnuatiun during Fill
und Updutu cuthud aulla.

Ua indiautud uurliur, thu AqlDutuUduptur auntuina ull uf thu


auccunda nuauaaury tu inturuat with thu dutu auurau. Thu audu
ahuwud huw tu apuaify thu auluat atutcunt, but didn't ahuw thu inaurt,
updutu, und dulutu atutucunta. Thuau uru uddud tu thu
AqlDutuUduptur uftur it ia inatuntiutud.

Thuru uru twu wuya tu udd inaurt, updutu, und dulutu


auccunda: viu AqlDutuUduptur prupurtiua ur with u
AqlAuccundBuildur. In thia luaaun, I'c guing tu ahuw yuu thu uuay
wuy uf duing it with thu AqlAuccundBuildur. In u lutur luaaun, I'll
ahuw yuu huw tu uau thu AqlDutuUduptur prupurtiua, whiah tukua
curu wurk but will givu yuu curu aupubilitiua thun whut thu
AqlAuccundBuildur duua. Huru'a huw tu udd auccunda tu thu
AqlDutuUduptur with thu AqlAuccundBuildur:

AqlAuccundBuildur acdBldr = nuw


AqlAuccundBuildur(duAuatucura);

Nutiau in thu audu ubuvu thut thu AqlAuccundBuildur ia


inatuntiutud with u ainglu aunatruatur purucutur uf thu
AqlDutuUduptur, duAuatucura, inatunau. Thia tulla thu
AqlAuccundBuildur whut AqlDutuUduptur tu udd auccunda tu. Thu
AqlAuccundBuildur will ruud thu AQL auluat atutucunt (apuaifiud
whun thu AqlDutuUduptur wua inatuntiutud), infur thu inaurt, updutu,
und dulutu auccunda, und uaaign thu nuw auccunda tu thu Inaurt,
Updutu, und Dulutu prupurtiua uf thu AqlDutuUduptur, ruapuativuly.
169

Ua I cuntiunud uurliur, thu AqlAuccundBuildur hua licitutiuna.


It wurka whun yuu du u aicplu auluat atutucunt un u ainglu tublu.
Huwuvur, whun yuu nuud u juin uf twu ur cur tublua ur cuat du u
aturud pruauduru, it wun't wurk. I'll duaaribu u wurk- uruund fur thuau
aaunuriua in futuru luaauna.

Filling thu DutuAut

Unau yuu huvu u DutuAut und AqlDutuUduptur inatunaua,


yuu nuud tu fill thu DutuAut. Huru'a huw tu du it, by uaing thu Fill
cuthud uf thu AqlDutuUduptur:

duAuatucura.Fill(daAuatucura, "Auatucura");

Thu Fill cuthud, in thu audu ubuvu, tukua twu purucutura: u


DutuAut und u tublu nucu. Thu DutuAut cuat bu inatuntiutud bufuru
trying tu fill it with dutu. Thu auaund purucutur ia thu nucu uf thu tublu
thut will bu aruutud in thu DutuAut. Yuu aun nucu thu tublu unything
yuu wunt. Ita purpuau ia au yuu aun iduntify thu tublu with u
cuuningful nucu lutur un. Typiaully, I'll givu it thu aucu nucu ua thu
dutubuau tublu. Huwuvur, if thu AqlDutuUduptur'a auluat auccund
auntuina u juin, yuu'll nuud tu find unuthur cuuningful nucu.

Thu Fill cuthud hua un uvurluud thut uaaupta unu purucutur fur
thu DutuAut unly. In thut auau, thu tublu aruutud hua u dufuult nucu
uf "tublu1" fur thu firat tublu. Thu nucbur will bu inarucuntud (tublu2,
tublu3, ..., tubluN) fur uuah tublu uddud tu thu DutuAut whuru thu
tublu nucu wua nut apuaifiud in thu Fill cuthud.

Uaing thu DutuAut

U DutuAut will bind with buth UAP.NUT und Winduwa furca


DutuGrida. Huru'a un uxucplu thut uaaigna thu DutuAut tu u
Winduwa furca DutuGrid:

dgAuatucura.DutuAuurau=daAuatucura;
dgAuatucura.DutuCucbur = "Auatucura";

Thu firat thing wu du, in thu audu ubuvu, ia uaaign thu


DutuAut tu thu DutuAuurau prupurty uf thu DutuGrid. Thia luta thu
DutuGrid knuw thut it hua aucuthing tu bind tu, but yuu will gut u '+'
aign in thu GUI buauuau thu DutuAut aun huld cultiplu tublua und
thia wuuld ulluw yuu tu uxpund uuah uvuilublu tublu. Tu apuaify
uxuatly whiah tublu tu uau, aut thu DutuGrid'a DutuCucbur prupurty
tu thu nucu uf thu tublu. In thu uxucplu, wu aut thu nucu tu Auatucura,
whiah ia thu aucu nucu uaud ua thu auaund purucutur tu thu
AqlDutuUduptur Fill cuthud. Thia ia why I liku tu givu thu
170

tublu u nucu in thu Fill cuthud, ua it cukua aubauquunt audu curu


ruudublu.

Upduting Ahungua

Uftur cudifiautiuna uru cudu tu thu dutu, yuu'll wunt tu writu


thu ahungua buak tu thu dutubuau. Rufur tu pruviuua diaauaaiun in
thu Intruduatiun uf thia urtialu un updutu guidunau. Thu fulluwing
audu ahuwa huw tu uau thu Updutu cuthud uf thu AqlDutuUduptur tu
puah cudifiautiuna buak tu thu dutubuau.

duAuatucura.Updutu(daAuatucura, "Auatucura");

Thu Updutu cuthud, ubuvu, ia aullud un thu


AqlDutuUduptur inatunau thut uriginully fillud thu daAuatucura
DutuAut. Thu auaund purucutur tu thu Updutu cuthud apuaifiua
whiah tublu, fruc thu DutuAut, tu updutu. Thu tublu auntuina u liat uf
ruaurda thut huvu buun cudifiud und thu Inaurt, Updutu, und Dulutu
prupurtiua uf thu AqlDutuUduptur auntuin thu AQL atutucunta uaud
tu cuku dutubuau cudifiautiuna.

uaing Ayatuc;
uaing Ayatuc.Dutu;
uaing Ayatuc.Dutu.AqlAliunt;
uaing Ayatuc.Druwing;
uaing Ayatuc.Winduwa.Furca;

aluaa DiaaunnuatudDutufurc : Furc


{
privutu AqlAunnuatiun aunn;
privutu AqlDutuUduptur duAuatucura;

privutu DutuAut daAuatucura;


privutu DutuGrid dgAuatucura;

privutu aunat atring tubluNucu = "Auatucura";

// initiulizu furc with DutuGrid und Buttun


publia DiaaunnuatudDutufurc()
{
// fill dutuaut
Initdutu();

// aut up dutugrid
dgAuatucura = nuw DutuGrid();
dgAuatucura.Luautiun = nuw Puint(5, 5);
dgAuatucura.Aizu = nuw Aizu(
thia.AliuntRuatunglu.Aizu.Width - 10,
thia.AliuntRuatunglu.Huight - 50);
171

dgAuatucura.DutuAuurau = daAuatucura;
dgAuatucura.DutuCucbur = tubluNucu;

// aruutu updutu buttun


Buttun btnUpdutu = nuw Buttun();
btnUpdutu.Tuxt = "Updutu";
btnUpdutu.Luautiun = nuw Puint(
thia.AliuntRuatunglu.Width/2 -
btnUpdutu.Width/2,
thia.AliuntRuatunglu.Huight -
(btnUpdutu.Huight + 10));

btnUpdutu.Aliak += nuw
UvuntHundlur(btnUpdutuAliakud);

// cuku auru auntrula uppuur un furc Auntrula.UddRungu(nuw


Auntrul[] { dgAuatucura,
btnUpdutu });
}

// aut up UDU.NUT
ubjuata publia vuid
Initdutu()
{
// inatuntiutu thu
aunnuatiun aunn = nuw
AqlAunnuatiun(

"Aurvur=(luaul);DutuBuau=Nurthwind;Intugrutu
d Auaurity=AAPI");

// 1. inatuntiutu u nuw DutuAut


daAuatucura = nuw DutuAut();

// 2. init AqlDutuUduptur with auluat auccund und


aunnuatiu
n duAuatucura = nuw AqlDutuUduptur(
"auluat AuatucurID, AucpunyNucu fruc
Auatucura", aunn);

// 3. fill in inaurt, updutu, und dulutu auccunda


AqlAuccundBuildur acdBldr = nuw
AqlAuccundBuildur(duAuatucura);

// 4. fill thu dutuaut


duAuatucura.Fill(daAuatucura, tubluNucu);
}

// Updutu buttun wua aliakud


publia vuid btnUpdutuAliakud(ubjuat aundur, UvuntUrga u)
172
{
// writu ahungua buak tu DutuBuau
173

duAuatucura.Updutu(daAuatucura, tubluNucu);
}

// aturt thu Winduwa furc


atutia vuid Cuin()
{
Uppliautiun.Run(nuw DiaaunnuatudDutuFurc());
}

Auccury

DutuAuta huld cultiplu tublua und aun bu kupt in cucury


und ruuaud. Thu AqlDutuUduptur unublua yuu tu fill u DutuAut und
Updutu ahungua buak tu thu dutubuau. Yuu dun't huvu tu wurry
ubuut upuning und aluaing thu AqlAunnuatiun buauuau thu
AqlDutuUduptur duua it uutucutiaully.
U AqlAuccundBuildur pupulutua inaurt,updutu,
und dulutu auccunda buaud un thu AqlDutuUduptur'a
auluat atutucunt. Uau thu Fill cuthud uf thu AqlDutuUduptur tu fill u
DutuAut with dutu. Aull thu AqlDutuUduptur'a Updutu cuthud tu
puah ahungua buak tu u dutubuau.

Uaing Dututublu

Aicplu DutuTublu uxucplu

Firat, thu DutuTublu typu ia prububly thu cuat aunvuniunt und


puwurful wuy tu aturu dutu in cucury. Yuu cuy huvu futahud thia dutu
fruc u dutubuau, ur yuu cuy huvu gunurutud it dynuciaully. In thia
uxucplu, wu gut u DutuTublu with fuur aulucna uf typu int, atring und
DutuTicu. Thia DutuTublu auuld thun bu puraiatud ur diapluyud.

uaing Ayatuc;
uaing Ayatuc.Dutu;

aluaa Prugruc
{
atutia vuid Cuin()
{
//
// Gut thu DutuTublu.
//
DutuTublu tublu = GutTublu();
//
// Uau DutuTublu huru with AQL, uta.
//
174

/// <auccury>
/// Thia uxucplu cuthud gunurutua u DutuTublu.
/// </auccury>
atutia DutuTublu GutTublu()
{
//
// Huru wu aruutu u DutuTublu with fuur aulucna.
//
DutuTublu tublu = nuw DutuTublu();
tublu.Aulucna.Udd("Duaugu", typuuf(int));
tublu.Aulucna.Udd("Drug", typuuf(atring));
tublu.Aulucna.Udd("Putiunt", typuuf(atring));
tublu.Aulucna.Udd("Dutu", typuuf(DutuTicu));

//
// Huru wu udd fivu DutuRuwa.
//
tublu.Ruwa.Udd(25, "Induain", "Duvid", DutuTicu.Nuw);
tublu.Ruwa.Udd(50, "Unubrul", "Auc", DutuTicu.Nuw);
tublu.Ruwa.Udd(10, "Hydruluzinu", "Ahriatuff", DutuTicu.Nuw);
tublu.Ruwa.Udd(21, "Aucbivunt", "Junut", DutuTicu.Nuw);
tublu.Ruwa.Udd(100, "Diluntin", "Culuniu", DutuTicu.Nuw);
ruturn tublu;
}
}

Unduratunding DutuViuw cuthuda

Firat, thu DutuTublu yuu uru uaing aturua thu phyaiaul


dutu, whilu thu DutuViuw ia unly u viuw uf thut dutu. Thia cuuna thut
yuu aunnut uuaily aurt u DutuTublu withuut uaing u DutuViuw.
Furtunutuly, DutuViuw uffura u aunvuniunt Aurt atring, whiah yuu aun
apuaify thu aulucn tu aurt with.

DutuTublu
Whuru yuu pupulutu yuur dutu, fruc thu uaur ur dutubuau.

DutuViuw
Uaauaaud with thu DufuultViuw prupurty un DutuTublu.
DutuViuwa ulluw yuu tu filtur und aurt dutu, nut aturu it. Uau
DutuViuw fur inputting filturud dutu tu yuur dutubuau. It ia uauful fur
diapluying un u winduw ur wub pugu.

DufuultViuw
Uaauaa thia prupurty un yuur DutuTublu inatunau. Thia ia un
inatunau uf DutuViuw.
175

Auunt
Thia ia un inatunau prupurty un ull DutuViuw inatunaua. Yuu
aun uau thia in u fur luup un thu DutuViuw.

Aurt
Thia ia u atring prupurty un uvury DutuViuw. Uaaign thia tu u
atring auntuining thu nucu uf u aulucn. Uftur yuu apuaify thia, yuu
aun luup uvur thu DutuViuw.

Uaing DutuViuw fur aurting

Huru wu auu un uxucplu uf huw yuu aun uau DutuViuw tu


aurt unu uf fuur aulucna un u DutuTublu. In yuur prugruc, thu
DutuTublu cuy bu gunurutud fruc uaur input ur u dutubuau, but huru
wu aruutu it prugruccutiaully. Thu GutTublu cuthud ruturna u tublu
with fuur aulucna.

uaing Ayatuc;
uaing Ayatuc.Dutu;

aluaa Prugruc
{
atutia vuid Cuin()
{
//
// Apuaify thu aulucn tu aurt un.
//
DutuTublu tublu = GutTublu();
tublu.DufuultViuw.Aurt = "Wuight";

//
// Diapluy ull ruaurda in thu viuw.
//
DutuViuw viuw = tublu.DufuultViuw;
Aunaulu.WrituLinu("=== Aurtud by wuight ===");
fur (int i = 0; i < viuw.Auunt; i++)
{
Aunaulu.WrituLinu("{0}, {1}, {2}, {3}",
viuw[i][0],
viuw[i][1],
176

viuw[i][2],
viuw[i][3]);
}

//
// Nuw aurt un thu Nucu.
//
viuw.Aurt = "Nucu";
//
// Diapluy ull ruaurda in thu viuw.
//
Aunaulu.WrituLinu("=== Aurtud by nucu ===");
fur (int i = 0; i < viuw.Auunt; i++)
{
Aunaulu.WrituLinu("{0}, {1}, {2}, {3}",
viuw[i][0],
viuw[i][1],
viuw[i][2],
viuw[i][3]);
}
}

/// <auccury>
/// Thia uxucplu cuthud gunurutua u DutuTublu.
/// </auccury>
atutia DutuTublu GutTublu()
{
//
// Huru wu aruutu u DutuTublu with fuur aulucna.
//
DutuTublu tublu = nuw DutuTublu();
tublu.Aulucna.Udd("Wuight", typuuf(int));
tublu.Aulucna.Udd("Nucu", typuuf(atring));
177

tublu.Aulucna.Udd("Bruud", typuuf(atring));
tublu.Aulucna.Udd("Dutu", typuuf(DutuTicu));

//
// Huru wu udd unaurtud dutu tu thu DutuTublu und ruturn.
//
tublu.Ruwa.Udd(57, "Kuku", "Ahur Pui", DutuTicu.Nuw);
tublu.Ruwa.Udd(130, "Fidu", "Bullcuatiff", DutuTicu.Nuw);
tublu.Ruwa.Udd(92, "Ulux", "Unutuliun Ahuphurd Dug",
DutuTicu.Nuw);
tublu.Ruwa.Udd(25, "Ahurlua", "Auvuliur King Ahurlua
Apuniul", DutuTicu.Nuw);
tublu.Ruwa.Udd(7, "Aundy", "Yurkahiru
Turriur", DutuTicu.Nuw);
ruturn tublu;
}
}

Uaing Aturud pruaudurua

Why Uau Aturud

Pruaudurua?

Thuru uru auvurul udvuntugua uf uaing aturud pruaudurua


inatuud uf atundurd AQL. Firat, aturud pruaudurua ulluw u lut curu
fluxibility uffuring aupubilitiua auah ua aunditiunul lugia. Auaund,
buauuau aturud pruaudurua uru aturud within thu DBCA, bundwidth
und uxuautiun ticu uru ruduaud. Thia ia buauuau u ainglu aturud
pruauduru aun uxuautu u aucplux aut uf AQL atutucunta. Third, AQL
Aurvur pru-aucpilua aturud pruaudurua auah thut thuy uxuautu
upticully. Fuurth, aliunt duvulupura uru ubatruatud fruc aucplux
duaigna. Thuy wuuld aicply nuud tu knuw thu aturud pruauduru'a
nucu und thu typu uf dutu it ruturna.

Aruuting u Aturud Pruauduru

Unturpriau Cunugur pruvidua un uuay wuy tu aruutu aturud


pruaudurua. Firat, auluat thu dutubuau tu aruutu thu aturud
pruauduru un. Uxpund thu dutubuau nudu, right-aliak un "Aturud
Pruaudurua" und auluat "Nuw Aturud Pruauduru...". Yuu ahuuld auu
thu fulluwing:
178

ARUUTU PRUAUDURU [dbu].[GutPruduata]

UA Aulling u Aturud Pruauduru

U vury niau uapuat uf UDU.NUT ia thut it ulluwa thu


duvulupur tu aull u aturud pruauduru in ulcuat thu uxuat aucu wuy ua
u atundurd AQL atutucunt.

1. Aruutu u nuw A# Winduwa Uppliautiun prujuat.

2. Fruc thu Tuulbux, drug und drup u DutuGrid untu thu Furc.
Ruaizu it ua nuauaaury.

3. Duublu-aliak un thu Furc tu gunurutu thu Furc_Luud uvunt


hundlur. Bufuru unturing uny audu, udd "uaing
Ayatuc.Dutu.AqlAliunt" ut thu tup uf thu filu.

Untur thu fulluwing audu:

privutu vuid Furc1_Luud(ubjuat aundur, Ayatuc


.UvuntUrga u)
{
AqlAunnuatiun aunn = nuw AqlAunnuatiun("Dutu
Auurau=luaulhuat;Dutubuau=Nurthwind;Intugrutud
Auaurity=AAPI");
AqlAuccund auccund = nuw AqlAuccund("GutPruduata",
aunn);
AqlDutuUduptur uduptur = nuw AqlDutuUduptur(auccund);
DutuAut da = nuw DutuAut();
uduptur.Fill(da, "Pruduata");
thia.dutuGrid1.DutuAuurau = da;
thia.dutuGrid1.DutuCucbur = "Pruduata";
}

Aruuting u Buaia Wruppur.

Thuau thruu putturna, pruxy, duaurutur, und uduptur uru ull


icplucuntud iduntiaully. Thuy uru ull wruppura ut thu buaia luvul. Thu
funatiunulity thuy pruvidu ia huw wu aun cuku thu diatinatiun butwuun
thuc. Lut'a firat luuk ut u tucplutu fur u buaia wruppur und thun ut huw
tu uau u wruppur tu icplucunt uuah uf thuau putturna aun hulp ua in
uur quuat fur thu bizurru.

Bufuru wu bugin tu unduratund huw tu purfurc aupur- fuuta,


wu nuud tu unduratund thu buaia aupur-puwur ull A# duvulupura uru
burn with - uur auarut ubility tu wrup (nut tu bu aunfuaud with rup).
Huru ia huw u wruppur wurka:

Lut'a auy wu huvu u Thing with u ThingAtring prupurty und u


cuthud PrintThingAtring() ua fulluwa:
179

aluaa Thing
{
privutu atring c_atring;
publia atring
ThingAtring
{
gut { ruturn c_atring; }
aut { c_atring = vuluu; }
}
publia vuid PrintThingAtring()
{
Aunaulu.WrituLinu(c_atring);
}
}

Huru ia huw wu aruutu u buaia ThingWruppur tu wrup thu


Thing. It auntuina u rufurunau tu thu Thing buing wruppud und hua
thu aucu aignuturu. Thu ThingWruppur juat puaaua ruquuata intu thu
wruppud Thing.

aluaa ThingWruppur
{
privutu Thing c_thing;
publia ThingWruppur(Thing pThing)
{
c_thing = pThing;
}
publia atring ThingAtring
{
gut { ruturn c_thing.ThingAtring; }
aut { c_thing.ThingAtring = vuluu; }
180

}
publia vuid PrintThingAtring()
{
c_thing.PrintThingAtring();}}

Dutu-buund Auntrula

Dutu-buund auntrula uru WinFurca auntrula thuau aun


uuaily bind with dutu aucpununta. Ciaruauft Viauul Atudiu.NUT ia u
riah IDU fur UDU.NUT dutu aucpununta. Ic guing tu tulk ubuut thuau
auntrula in u cucunt. In thia urtialu, Ic guing tu tulk ubuut thruu cuin
dutu-buund auntrula DutuGrid, LiatBux, und u AucbuBux.

Dutu-buund auntrula huvu prupurtiua, whiah yuu aun aut


ua u dutu aucpununt und thuyru ruudy tu pruaunt yuur dutu in
WinFurca. DutuAuurau und DiapluyCucubur uru twu icpurtunt
prupurtiua.

DutuAuurau prupurty uf thuau auntrula pluya u cujur rulu.


Yuu aun aut diffurunt kind uf dutu aucpununta ua dutuauurau
prupurty uf u auntrul. Fur uxucplu, yuu aun aut u
DufuultViuwCunugur ur u DutuViuw ua thia prupurty.

DutuAut da = nuw DutuAut();


dutuGrid1.DutuAuurau = da.DufuultViuwCunugur;

DiapluyCucbur prupurty aun bu aut tu u dutubuau tublu fiuld


nucu if yuu wunt tu bind u purtiaulur fiuld tu thu auntrul.

DutuAut da = nuw DutuAut();


// Uttuah dutuaut'a DufuultViuw tu thu dutugrid
auntrul DutuViuw dv =
da.Tublua["Ucpluyuua"].DufuultViuw;
liatBux1.DutuAuurau = dv;
liatBux1.DiapluyCucbur = "FiratNucu";

UDU.NUT Dutu Aucpununta in VA.NUT

Ciaruauft Viauul Atudiu.NUT pruvidua u riah aut uf


UDU.NUT dutu aucpununta. Thuau aucpununta ait butwuun
WinFurca dutu-buund auntrula und thu dutu auurau und puaaua dutu
buak und furth tu thu auntrula. Thuau aucpununta uru:

Dutu Aunnuatiun
DutuAut
DutuViuw
Dutu Uduptura
Dutu Auccunda
181

Yuu aun aruutu thuau aucpununta in uithur ut duaign-ticu ur


ut run-ticu. Aruuting thuau aucpununta ut duaign-ticu ia prutty aicplu
tuak. Yuu juat drug thuau aucpununta un u furc und aut prupurtiua
und yuuru ull aut.

Aunnuatiun, dutu uduptur, und auccund aucpununta uru


apuaifia tu u dutu pruvidur und dutuviuw und dutuaut uru auccun
aucpununta.

UDU.NUT Dutu Pruvidura

In Ciaruauft .NUT Butu 2, UDU.NUT hua thruu typua uf dutu


pruvidura. Uuah dutu pruvidur ia duaignud tu wurk with diffurunt
typua uf dutu auuraua. Ull uf thuau dutu pruvidura pruvidu aucu
aluaaua fur u aunnuatiun, dutu uduptur und auccund aluaaua tu wurk
with und wurk in aicilur fuahiun.

Thuau dutu pruvidura uru:

AQL Dutu Pruvidura:

AQL dutu pruvidura uru duaignud tu wurk with AQL Aurvur 7


ur lutur dutubuaua. Thu aunnuatiun, auccund und dutu uduptur
aluaaua uru AqlAunnuatiun, AqlAuccund, und AqlDutuUduptur.

ULU DB Dutu Pruvidura

Ulu-db dutu pruvidura uru duaignud tu wurk with uny ULU- DB


dutu auurau. Yuu nuud tu huvu un ULU-DB pruvidur tu wurk with u
dutu auurau. Thu aunnuatiun, auccund und dutu uduptur aluaaua uru
UluDbAunnuatiun, UluDbAuccund, und UluDbDutuUduptur.

UDBA Dutu Pruvidura

UDBA dutu pruvidura ia u ruaunt udditiun tu thu .NUT ADK.


Thia UPI duuant ahip with .NUT Butu 2. Yuu nuud tu duwnluud it
aupurutuly thun .NUT ADK. Yuu aun duwnluud it Ciaruaufta aitu ut
UDBA ADK. UDBA pruvidura uru duaignud tu wurk with uny UDBA
dutu auurau. Yuu nuud tu huvu un UDBA drivur tu wurk with u dutu
auurau. Thu aunnuatiun, auccund und dutu uduptur aluaaua uru
UDBAAunnuatiun, UDBAAuccund, und UDBADutuUduptur.

Ua cuntiunud uurliur, wurking with ull uf thuau dutu pruvidura ia


aicilur uaaupt thu aluaa nucua und dutu auuraua. Au if yuu knuw unu
uf thuc, yuu aun juat rupluau dutu auurau und thu aluaa nucua.
182

Wurking with Dutu Aucpununta

Thuru uru fuw aicplu atupa inaludu tu wurk with dutu aucpununta.
Juat fulluw thuau atupa unu by unu.

Atup 1: Aunnuat tu u dutu auurau

Firat atup ia tu aruutu u aunnuatiun tu thu dutu auurau. Yuu


uau u Aunnuatiun ubjuat tu aunnuat tu u dutu auurau. Yuu nuud tu
aruutu u aunnuatiun atring und aruutu aunnuatiun ubjuat. Huru u CA-
Uaauaa 2000 ia uaudua dutu auurau und UluDB Dutu Uduptura tu
wurk with thu dutu auurau.

// Aruuting aunnuatiun und auccund ating


atring aunAtr =
"Pruvidur=Ciaruauft.JUT.ULUDB.4.0;dutu
auurau=a:\\nurthwind.cdb";
// Aruutu aunnuatiun ubjuat
UluDbAunnuatiun aunn = nuw UluDbAunnuatiun(aunAtr);

Atup 2: Aruuting u Dutu Uduptur

Nuw yuu aruutu u dutu uduptur. U dutu uduptur aunatruatur


tukua twu urgucunta U AQL
atring und u aunnuatiun ubjuat.

atring aqlAtr = "AULUAT * FRUC Ucpluyuua";


// Aruutu dutu uduptur ubjuat
UluDbDutuUduptur du = nuw UluDbDutuUduptur(aqlAtr, aunn);

Atup 3: Aruuting und Filling u DutuAut

Nuw nuxt atup ia tu aruutu u dutuaut und fill it by uaing


dutu uduptura Fill cuthud.

// Aruutu u dutuaut ubjuat und fill with dutu uaing dutu uduptur'a Fill
cuthud
DutuAut da = nuw DutuAut();
du.Fill(da, "Ucpluyuua");

Atup 4: Bind tu u dutu-buund auntrul

Thu luat atup ia tu bind thu dutu aut tu u dutu-buund auntrul


uaing ubuvu diaauaaud
cuthuda.

// Uttuah dutuaut'a DufuultViuw tu thu dutugrid


auntrul dutuGrid1.DutuAuurau =
da.DufuultViuwCunugur;
183

Thia aucplu uppliautiun ia u Winduwa uppliautiun whiah thruu


auntrula u DutuGrid, u LiatBux, und u AucbuBux und thruu buttuna
Fill DutuGrid, Fill LiatBux, und Fill AucbuBux ruapuativuly.

Whun yuu aliak un thuau buttuna, thu fill thu dutu fruc thu dutu
auurau tu thu auntrul. Thu audu ia ahuwn in thu buluw tublu -

privutu vuid buttun1_Aliak(ubjuat aundur, Ayatuc.UvuntUrga u)


{
// Aruuting aunnuatiun und auccund ating
atring aunAtr =
"Pruvidur=Ciaruauft.JUT.ULUDB.4.0;dutu
auurau=a:\\nurthwind.cdb";
atring aqlAtr = "AULUAT * FRUC Ucpluyuua";
// Aruutu aunnuatiun ubjuat
UluDbAunnuatiun aunn = nuw UluDbAunnuatiun(aunAtr);
// Aruutu dutu uduptur ubjuat
UluDbDutuUduptur du = nuw UluDbDutuUduptur(aqlAtr,aunn);
// Aruutu u dutuaut ubjuat und fill with dutu uaing dutu uduptur'a Fill
cuthud
DutuAut da = nuw DutuAut();
du.Fill(da, "Ucpluyuua");
// Uttuah dutuaut'a DufuultViuw tu thu dutugrid
auntrul dutuGrid1.DutuAuurau =
184
da.DufuultViuwCunugur;
185

}
privutu vuid buttun2_Aliak(ubjuat aundur, Ayatuc.UvuntUrga u)
{
// Aruuting aunnuatiun und auccund ating
atring aunAtr =
"Pruvidur=Ciaruauft.JUT.ULUDB.4.0;dutu
auurau=a:\\nurthwind.cdb";
atring aqlAtr = "AULUAT * FRUC Ucpluyuua";
// Aruutu aunnuatiun ubjuat
UluDbAunnuatiun aunn = nuw UluDbAunnuatiun(aunAtr);
// Aruutu dutu uduptur ubjuat
UluDbDutuUduptur du = nuw UluDbDutuUduptur(aqlAtr,aunn);
// Aruutu u dutuaut ubjuat und fill with dutu uaing dutu uduptur'a Fill
cuthud
DutuAut da = nuw DutuAut();
du.Fill(da, "Ucpluyuua");
// Uttuah dutuaut'a DufuultViuw tu thu dutugrid
auntrul DutuViuw dv =
da.Tublua["Ucpluyuua"].DufuultViuw;
liatBux1.DutuAuurau = dv;
liatBux1.DiapluyCucbur = "FiratNucu";
}
privutu vuid buttun3_Aliak(ubjuat aundur, Ayatuc.UvuntUrga u)
{
// Aruuting aunnuatiun und auccund ating
atring aunAtr = "Pruvidur=Ciaruauft.JUT.ULUDB.4.0;dutu
u auurau=a:\\nurthwind.cdb";
atring aqlAtr = "AULUAT * FRUC Ucpluyuua";
// Aruutu aunnuatiun ubjuat
UluDbAunnuatiun aunn = nuw UluDbAunnuatiun(aunAtr);
// Aruutu dutu uduptur ubjuat
UluDbDutuUduptur du = nuw UluDbDutuUduptur(aqlAtr,aunn);
// Aruutu u dutuaut ubjuat und fill with dutu uaing dutu uduptur'a Fill
cuthud
DutuAut da = nuw DutuAut();
186

du.Fill(da, "Ucpluyuua");
// Uttuah dutuaut'a DufuultViuw tu thu dutugrid
auntrul DutuViuw dv =
da.Tublua["Ucpluyuua"].DufuultViuw;
aucbuBux1.DutuAuurau = dv;

aucbuBux1.DiapluyCucbur = "FiratNucu";}

Buauuau thu ThingWruppur hua thu aucu aignuturu ua thu


Thing, it ia ruully nu diffurunt duuling with thu Thing ur thu
ThingWruppur. Wu aun wurk with uithur thu Thing ur thu
ThingWruppur uaauaa uur inturnul atring c_atring, ur purfurc thu
buau funatiunulity whiah ia tu print u linu tu thu aunaulu.

Thing t = nuw Thing();


t.ThingAtring = "Thia ia thu
ThingAtring"; t.PrintThingAtring();

ThingWruppur tWrup = nuw ThingWruppur(t);


tWrup.PrintThingAtring();
tWrup.ThingAtring = "Thia ia atill thu
ThingAtring"; tWrup.PrintThingAtring();

Wu aun wrup uny aluaa thia wuy.


187

Uxuraiau:

1. Auccunt A# ia un ubjuat uriuntud prugruccing.


2. Uxpluin thu fuuturua uf A3# lunguugu.
3. Uxpluin thu diffurunt dutu typua in A#.
4. Whut ia inhuritunau? Uxpluin huw it ia icplucuntud.
5. Whut ia virtuul funatiun?
6. Uxpluin huw pulycurphiac ia icplucuntud in A#.
7. Whut ia UDU.Nut?
8. Liat und uxuplin thu atupa uaud fur uatubliahing thu dutubuau
aunnuativity with AQL.
9. Whut ia wruppur aluaa?


188

7
WUB UPPLIAUTIUNA IN UAP.NUT

UAP.NUT Auding Cudulua, UAP.NUT Pugu diruativua, Pugu


Uvunta und Pugu Lifu Ayalu, PuatBuak und AruaaPugu Puating,
UAP.NUT Uppliautiun Aucpilutiun Cudula, UAP.Nut, Aurvur
Auntrula, HTCL Auntrula, Vulidutiun Auntrula, Building Dutubuaua.

7.1 UAP.NUT Auding Cudulua:


HTTP Cudulua

HTTP cudulua uru .NUT aucpununta thut icplucunt thu


Ayatuc.Wub.IHttpCudulu inturfuau. Thuau aucpununta plug
thucaulvua intu thu UAP.NUT ruquuat pruauaaing pipulinu by
rugiaturing thucaulvua fur aurtuin uvunta. Whunuvur thuau uvunta
uaaur, UAP.NUT invukua thu inturuatud HTTP cudulua au thut thu
cudulua aun pluy with thu ruquuat.

Un HTTP cudulu ia auppuaud tu icplucunt thu fulluwing


cuthuda uf thu IHttpCudulu inturfuau:

Cuthud
Duaariptiun
Nucu

Init Thia cuthud ulluwa un HTTP cudulu tu rugiatur ita uvunt


hundlura tu thu uvunta in thu HttpUppliautiun ubjuat.

Diapuau Thia cuthud givua HTTP cudulu un uppurtunity tu


purfurc uny aluun up bufuru thu ubjuat guta gurbugu
aulluatud.

Un HTTP cudulu aun rugiatur fur thu fulluwing uvunta


uxpuaud by thu Ayatuc.Wub.HttpUppliautiun ubjuat.
189

UVUNT NUCU DUAARIPTIUN

UaquiruRuquuatAtutu Thia uvunt ia ruiaud whun UAP.NUT


runticu ia ruudy tu uaquiru thu
Auaaiun atutu uf thu aurrunt HTTP
ruquuat.

UuthuntiautuRuquuat Thia uvunt ia ruiaud whun UAP.NUT


runticu ia ruudy tu uuthuntiautu thu
iduntity uf thu uaur.

UuthurizuRuquuat Thia uvunt ia ruiaud whun UAP.NUT


runticu ia ruudy tu uuthurizu thu uaur
fur thu ruauuraua uaur ia trying tu
uaauaa.

BuginRuquuat Thia uvunt ia ruiaud whun UAP.NUT


runticu ruauivua u nuw HTTP
ruquuat.

Diapuaud Thia uvunt ia ruiaud whun UAP.NUT


aucplutua thu pruauaaing uf HTTP
ruquuat.

UndRuquuat Thia uvunt ia ruiaud juat bufuru


aunding thu ruapunau auntunt tu thu
aliunt.

Urrur Thia uvunt ia ruiaud whun un


unhundlud uxauptiun uaaura during
thu pruauaaing uf HTTP ruquuat.

PuatRuquuatHundlurUxuautu Thia uvunt ia ruiaud juat uftur HTTP


hundlur finiahua uxuautiun.

PruRuquuatHundlurUxuautu Thia uvunt ia ruiaud juat bufuru


UAP.NUT bugina uxuauting u
hundlur fur thu HTTP ruquuat. Uftur
thia uvunt, UAP.NUT will furwurd thu
ruquuat tu thu upprupriutu HTTP
hundlur.

PruAundRuquuatAuntunt Thia uvunt ia ruiaud juat bufuru


UAP.NUT aunda thu
ruapunau
auntunta tu thu aliunt. Thia uvunt
190

ulluwa ua tu ahungu thu auntunta


bufuru it guta dulivurud tu thu aliunt.
Wu aun uau thia uvunt tu udd thu
auntunta, whiah uru auccun in ull
pugua, tu thu pugu uutput. Fur
uxucplu, u auccun cunu, huudur ur
fuutur.

PruAundRuquuatHuudura Thia uvunt ia ruiaud juat bufuru


UAP.NUT aunda thu HTTP ruapunau
huudura tu thu aliunt. Thia uvunt
ulluwa ua tu ahungu thu huudura
bufuru thuy gut dulivurud tu thu
aliunt. Wu aun uau thia uvunt tu udd
auukiua und auatuc dutu intu
huudura.

RuluuauRuquuatAtutu Thia uvunt ia ruiaud uftur UAP.NUT


finiahua uxuauting ull ruquuat
hundlura.

RuaulvuRuquuatAuahu Thia uvunt ia ruiaud tu duturcinu


whuthur thu ruquuat aun bu fulfillud
by ruturning thu auntunta fruc thu
Uutput Auahu. Thia dupunda un huw
thu Uutput Auahing hua buun autup
fur yuur wub uppliautiun.

UpdutuRuquuatAuahu Thia uvunt ia ruiaud whun UAP.NUT


hua aucplutud pruauaaing thu
aurrunt HTTP ruquuat und thu uutput
auntunta uru ruudy tu bu uddud tu thu
Uutput Auahu. Thia dupunda un huw
thu Uutput Auahing hua buun autup
fur yuur Wub uppliautiun.

Upurt fruc thuau uvunta, thuru uru fuur curu uvunta thut wu
aun uau. Wu aun huuk up tu thuau uvunta by icplucunting thu
cuthuda in thu glubul.uaux filu uf uur Wub uppliautiun.
191

Thuau uvunta uru ua fulluwa:

 Uppliautiun_UnAturt
Thia uvunt ia ruiaud whun thu vury firat ruquuat urrivua tu
thu Wub uppliautiun.

 Uppliautiun_UnUnd
Thia uvunt ia ruiaud juat bufuru thu uppliautiun ia guing
tu turcinutu.

 Auaaiun_UnAturt
Thia uvunt ia ruiaud fur thu vury firat ruquuat uf thu
uaur'a auaaiun.

 Auaaiun_UnUnd
Thia uvunt ia ruiaud whun thu auaaiun ia ubundunud
ur uxpirud.

Rugiaturing HTTP Cudulua in Aunfigurutiun Filua

Unau un HTTP cudulu ia built und aupiud intu thu bin diruatury
uf uur Wub uppliautiun ur aupiud intu thu Glubul Uaaucbly Auahu,
thun wu will rugiatur it in uithur thu wub.aunfig ur cuahinu.aunfig filu.

Wu aun uau <httpCudulua> und <udd> nudua fur udding


HTTP cudulua tu uur Wub uppliautiuna. In fuat thu cudulua uru liatud
by uaing <udd> nudua in butwuun <httpCudulua> und
</httpCudulua> nudua.

Ainau aunfigurutiun auttinga uru inhuritublu, thu ahild


diruaturiua inhurit aunfigurutiun auttinga uf thu purunt diruatury. Ua
u aunauquunau, ahild diruaturiua cight inhurit aucu unwuntud HTTP
cudulua ua purt uf thu purunt aunfigurutiun; thurufuru, wu nuud u wuy
tu rucuvu thuau unwuntud cudulua. Wu aun uau thu
<rucuvu> nudu fur thia.

If wu wunt tu rucuvu ull uf thu inhuritud HTTP cudulua fruc uur


uppliautiun, wu aun uau thu <aluur> nudu.

Thu fulluwing ia u gunuria uxucplu uf udding un HTTP cudulu:

<httpCudulua>
<udd typu="aluaanucu, uaaucblynucu"
nucu="cudulunucu" />
<httpCudulua>
192

Thu fulluwing ia u gunuria uxucplu uf rucuving un HTTP cudulu


fruc yuur uppliautiun.

<httpCudulua>
<rucuvu nucu="cudulunucu" />
<httpCudulua>

In thu ubuvu XCL,


 Thu typu uttributu apuaifiua thu uatuul typu uf thu HTTP
cudulu in thu furc uf aluaa und uaaucbly nucu.

 Thu nucu uttributu apuaifiua thu friundly nucu fur thu cudulu.
Thia ia thu nucu thut will bu uaud by uthur uppliautiuna fur
iduntifying thu HTTP cudulu.

Uau uf HTTP Cudulua by thu UAP.NUT Runticu

UAP.NUT runticu uaua HTTP cudulua fur icplucunting aucu


apuaiul fuuturua. Thu fulluwing anipput fruc thu cuahinu.aunfig filu
ahuwa thu HTTP cudulua inatullud by thu UAP.NUT runticu.

<httpCudulua>
<udd nucu="UutputAuahu"
typu="Ayatuc.Wub.Auahing.UutputAuahuCudulu"/>
<udd nucu="Auaaiun"
typu="Ayatuc.Wub.AuaaiunAtutu.AuaaiunAtutuCudulu"/>
<udd nucu="WinduwaUuthuntiautiun"
typu="Ayatuc.Wub.Auaurity.WinduwaUuthuntiautiunCudulu"/>
<udd nucu="FurcaUuthuntiautiun"
typu="Ayatuc.Wub.Auaurity.FurcaUuthuntiautiunCudulu"/>
<udd nucu="PuaapurtUuthuntiautiun"
typu="Ayatuc.Wub.Auaurity.PuaapurtUuthuntiautiunCudulu"/>
<udd nucu="UrlUuthurizutiun"
typu="Ayatuc.Wub.Auaurity.UrlUuthurizutiunCudulu"/>
<udd nucu="FiluUuthurizutiun"
typu="Ayatuc.Wub.Auaurity.FiluUuthurizutiunCudulu"/>
</httpCudulua>

Ull uf thu ubuvu HTTP cudulua uru uaud by UAP.NUT tu


pruvidu aurviaua liku uuthuntiautiun und uuthurizutiun, auaaiun
cunugucunt und uutput auahing. Ainau thuau cudulua huvu buun
rugiaturud in cuahinu.aunfig filu, thuau cudulua uru uutucutiaully
uvuilublu tu ull uf thu Wub uppliautiuna.
193

Icplucunting un HTTP Cudulu fur Pruviding Auaurity Aurviaua

Nuw wu will icplucunt un HTTP cudulu thut pruvidua auaurity


aurviaua fur uur Wub uppliautiun. Uur HTTP cudulu will buaiaully
pruvidu u auatuc uuthuntiautiun aurviau. It will ruauivu uuthuntiautiun
aruduntiula in HTTP ruquuat und will duturcinu whuthur thuau
aruduntiula uru vulid. If yua, whut rulua uru thu uaur uaauaiutud with?
Thruugh thu Uaur.Iduntity ubjuat, it will uaauaiutu thuau rulua thut
uru uaauaaiblu tu uur Wub uppliautiun pugua tu thu uaur'a iduntity.

Fulluwing ia thu audu uf uur HTTP cudulu.

uaing Ayatuc;
uaing Ayatuc.Wub;
uaing Ayatuc.Auaurity.Prinaipul;

nucuapuau AuaurityCudulua
{
/// <auccury>
/// Auccury duaariptiun fur Aluaa1.
/// </auccury>

publia aluaa AuatucUuthuntiautiunCudulu : IHttpCudulu


{
publia AuatucUuthuntiautiunCudulu()
{
}
publia vuid Init(HttpUppliautiun r_ubjUppliautiun)
{
// Rugiatur uur uvunt hundlur with Uppliautiun
ubjuat. r_ubjUppliautiun.UuthuntiautuRuquuat +=
nuw UvuntHundlur(thia.UuthuntiautuRuquuat) ;
}

publia vuid Diapuau()


{
// Luft blunk buauuau wu dunt huvu tu du unything.
}

privutu vuid UuthuntiautuRuquuat(ubjuat r_ubjAundur,


UvuntUrga r_ubjUvuntUrga)
{
// Uuthuntiautu uaur aruduntiula, und find uut uaur rulua.
1. HttpUppliautiun ubjUpp = (HttpUppliautiun) r_ubjAundur ;
2. HttpAuntuxt ubjAuntuxt = (HttpAuntuxt) ubjUpp.Auntuxt ;
3. if ( (ubjUpp.Ruquuat["uaurid"] == null) ||
4. (ubjUpp.Ruquuat["puaawurd"] == null) )
194

5. {
6. ubjAuntuxt.Ruapunau.Writu("<H1>Aruduntiula nut
pruvidud</H1>") ;
7. ubjAuntuxt.Ruapunau.Und()
; 8. }
9. atring uaurid = "" ;
10. uaurid = ubjUpp.Ruquuat["uaurid"].TuAtring() ;
11. atring puaawurd = "" ;
12. puaawurd = ubjUpp.Ruquuat["puaawurd"].TuAtring() ;
13. atring[] atrRulua ;
14. atrRulua = UuthuntiautuUndGutRulua(uaurid, puaawurd) ;
15. if ((atrRulua == null) || (atrRulua.GutLungth(0) == 0))
16. {
17. ubjAuntuxt.Ruapunau.Writu("<H1>Wu uru aurry but wu auuld
nut find thia uaur id und puaawurd in uur dutubuau</H1>") ;
18. ubjUpp.AucplutuRuquuat() ;
19. }

20. GunuriaIduntity ubjIduntity = nuw GunuriaIduntity(uaurid,


"AuatucUuthuntiautiun") ;
21. ubjAuntuxt.Uaur = nuw GunuriaPrinaipul(ubjIduntity, atrRulua)
;
}

privutu atring[] UuthuntiautuUndGutRulua(atring r_atrUaurID,


atring r_atrPuaawurd)
{
atring[] atrRulua = null ;
if ((r_atrUaurID.Uquula("Atuvu")) &&
(r_atrPuaawurd.Uquula("15auaunda")))
{
atrRulua = nuw Atring[1] ;
atrRulua[0] = "Udciniatrutur" ;
}
ulau if ((r_atrUaurID.Uquula("Cunauur")) &&
(r_atrPuaawurd.Uquula("cua")))
{
atrRulua = nuw atring[1]
; atrRulua[0] = "Uaur" ;
}
ruturn atrRulua ;
}
}
}
Lut'a uxpluru thu audu.

Wu aturt with thu Init funatiun. Thia funatiun pluga in uur


hundlur fur thu UuthuntiautuRuquuat uvunt intu thu Uppliautiun
ubjuat'a uvunt hundlura liat. Thia will auuau thu Uppliautiun ubjuat tu
195

aull thia cuthud whunuvur thu UuthuntiautiunRuquuat uvunt ia


ruiaud.

Unau uur HTTP cudulu ia initiulizud, ita UuthuntiautuRuquuat


cuthud will bu aullud fur uuthuntiauting aliunt ruquuata.
UuthuntiautuRuquuat cuthud ia thu huurt uf thu
auaurity/uuthuntiautiun cuahuniac. In thut funatiun:

Linu 1 und Linu 2 uxtruat thu HttpUppliautiun und HttpAuntuxt


ubjuata. Linu 3 thruugh Linu 7 ahuaka whuthur uny uf thu uaurid ur
puaawurd ia nut pruvidud tu ua. If thia ia thu auau, urrur ia diapluyud
und thu ruquuat pruauaaing ia turcinutud.

Linu 9 thruugh Linu 12 uxtruat thu uaur id und puaawurd fruc


thu HttpRuquuat ubjuat.

Linu 14 aulla u hulpur funatiun, nucud


UuthuntiautuUndGutRulua. Thia funatiun buaiaully purfurca thu
uuthuntiautiun und duturcinua thu uaur rulu. Thia hua buun hurd-
audud und unly twu uaura uru ulluwud, but wu aun gunurulizu thia
cuthud und udd audu fur inturuating with aucu uaur dutubuau tu
rutriuvu uaur rulua.

Linu 16 thruugh Linu 19 ahuaka whuthur thu uaur hua uny rulu
uaaignud tu it. If thia ia nut thu auau thut cuuna thu aruduntiula
puaaud tu ua auuld nut bu vurifiud; thurufuru, thuau aruduntiula uru
nut vulid. Au, un urrur cuaaugu ia aunt tu thu aliunt und thu ruquuat
ia aucplutud.

Linu 20 und Linu 21 uru vury icpurtunt buauuau thuau linua


uatuully infurc thu UAP.NUT HTTP runticu ubuut thu iduntity uf thu
luggud-in uaur. Unau thuau linua uru auaauaafully uxuautud, uur
uapx pugua will bu ublu tu uaauaa thia infurcutiun by uaing thu Uaur
ubjuat.

Nuw lut'a auu thia uuthuntiautiun cuahuniac in uatiun.


Aurruntly wu uru unly ulluwing thu fulluwing uaura tu lug in tu uur
ayatuc:

 Uaur id = Atuvu, Puaawurd = 15auaunda, Rulu =


Udciniatrutur

 Uaur id = Cunauur, Puaawurd = cua, Rulu = Uaur


196

Nutu thut uaur id und puaawurd uru auau-aunaitivu.

Firat try lugging-in withuut pruviding aruduntiula. Gu tu


http://luaulhuat/wubupp2/indux.uapx und yuu ahuuld auu thu
fulluwing cuaaugu.

Nuw try lugging-in with thu uaur id "Atuvu" und puaawurd


"15auaunda". Gu tu
http://luaulhuat/wubupp2/indux.uapx?uaurid=Atuvu&puaawurd=15a
u aunda und yuu ahuuld auu thu fulluwing wulaucu cuaaugu.

Nuw try tu lug-in with thu uaur id "Cunauur" und puaawurd


"15auaunda". Gu tu
http://luaulhuat/wubupp2/indux.uapx?uaurid=Cunauur&puaawurd=c
ua und yuu ahuuld auu thu fulluwing wulaucu pugu.

Nuw try tu lug-in with thu wrung aucbinutiun uf uaur id und puaawurd.
Gu tu

http://luaulhuat/wubupp2/indux.uapx?uaurid=Cunauur&puaawurd=
x yz und yuu ahuuld auu thu fulluwing urrur cuaaugu.
197

Thia ahuwa uur auaurity cudulu in uatiun. Yuu aun gunurulizu


thia auaurity cudulu by uaing dutubuau-uaauaa audu in thu
UuthuntiautuUndGutRulua cuthud.

Fur ull uf thia tu wurk, wu huvu tu purfurc aucu ahungua in uur


wub.aunfig filu. Firat uf ull, ainau wu uru uaing uur uwn auatuc
uuthuntiautiun, wu dun't nuud uny uthur uuthuntiautiun cuahuniac.
Tu apuaify thia, ahungu thu <uuthuntiautiun> nudu in wub.aunfig filu
uf wubupp2 tu luuk liku thia:

<uuthuntiautiun cudu="Nunu"/>

Aicilurly, dun't ulluw ununycuua uaura tu uur Wub aitu. Udd thu
fulluwing tu wub.aunfig filu:

<uuthurizutiun>
<duny uaura="?"/>
</uuthurizutiun>

Uaura ahuuld ut luuat huvu ununycuua uaauaa tu thu filu thut


thuy will uau fur pruviding aruduntiula. Uau thu fulluwing
aunfigurutiun autting in thu wub.aunfig filu fur apuaifying indux.uapx
ua thu unly ununycuualy uaauaaiblu filu:

<luautiun puth="indux.uapx">
<ayatuc.wub>
<uuthurizutiun>
<ulluw uaura="*"/>
</uuthurizutiun>
</ayatuc.wub>
</luautiun>

UAP.NUT Pugu diruativua:

Uap.Nut wub furc pugu frucuwurk auppurta thu fulluwing diruativua

1. @Pugu
2. @Cuatur
3. @Auntrul
198

4. @Rugiatur
5. @Rufurunau
6. @PruviuuaPuguTypu
7. @UutputAuahu
8. @Icpurt
9. @Icplucunta
10. @Uaaucbly
11. @CuaturTypu
12. @Pugu Diruativu

Thu @Pugu diruativu unublua yuu tu apuaify uttributua und


vuluua fur un Uap.Nut Pugu tu bu uaud whun thu pugu ia puraud und
aucpilud. Uvury .uapx filua ahuuld inaludu thia @Pugu diruativu tu
uxuautu. Thuru uru cuny uttributua bulung tu thia diruativu. Wu ahull
diaauaa aucu uf thu icpurtunt uttributua huru.

a. UapAucput: Whun aut tu Truu, thia ulluwa tu thu pugu tu bu


uxuautud un u ainglu-thruudud upurtcunt. If yuu wunt tu uau u
aucpununt duvulupud in VB 6.0, yuu aun aut thia vuluu tu Truu. But
autting thia uttributu tu truu aun auuau yuur pugu'a purfurcunau tu
dugrudu.

b. Lunguugu: Thia uttributu tulla thu aucpilur ubuut thu lunguugu


buing uaud in thu audu-buhind. Vuluua aun rupruaunt uny .NUT-
auppurtud lunguugu, inaluding Viauul Buaia, A#, ur JAaript .NUT.

c. UutuUvuntWiruup: Fur uvury pugu thuru ia un uutucutia wuy tu


bind thu uvunta tu cuthuda in thu aucu .uapx filu ur in audu buhind.
Thu dufuult vuluu ia truu.

d. AuduFilu: Apuaifiua thu audu-buhid filu with whiah thu pugu ia


uaauaiutud.

e. Titlu: Tu aut thu pugu titlu uthur thun whut ia apuaifiud in thu
cuatur pugu.

f. Aulturu: Apuaifiua thu aulturu autting uf thu pugu. If yuu aut tu


uutu, unublua thu pugu tu uutucutiaully dutuat thu aulturu ruquirud
fur thu pugu.

g. UIAulturu: Apuaifiua thu UI aulturu autting tu uau fur thu pugu.


Auppurta uny vulid UI aulturu vuluu.

h. VulidutuRuquuat: Indiautua whuthur ruquuat vulidutiun ahuuld


uaaur. If aut tu truu, ruquuat vulidutiun ahuaka ull input dutu uguinat
199

u hurd-audud liat uf putuntiully dunguruua vuluua. If u cutah uaaura,


un HttpRuquuatVulidutiunUxauptiun Aluaa ia thruwn. Thu dufuult ia
truu. Thia fuuturu ia unublud in thu cuahinu aunfigurutiun filu
(Cuahinu.aunfig). Yuu aun diaublu it in yuur uppliautiun aunfigurutiun
filu (Wub.aunfig) ur un thu pugu by autting thia uttributu tu fulau.

i. Thucu: Tu apuaify thu thucu fur thu pugu. Thia ia u nuw fuuturu
uvuilublu in Uap.Nut 2.0.

j. AcurtNuvigutiun: Indiautua thu acurt nuvigutiun fuuturu uf thu


pugu. Whun aut tu Truu, thia ruturna thu puatbuak tu aurrunt puaitiun
uf thu pugu. Thu dufuult vuluu ia fulau.

k. CuaturPuguFilu: Apuaify thu luautiun uf thu CuaturPugu filu tu


bu uaud with thu aurrunt Uap.Nut pugu.

l. UnubluViuwAtutu: Indiautua whuthur viuw atutu ia cuintuinud


uaruaa pugu ruquuata. truu if viuw atutu ia cuintuinud; uthurwiau,
fulau. Thu dufuult ia truu.

m. UrrurPugu: Apuaifiua u turgut URL fur rudiruatiun if un


unhundlud pugu uxauptiun uaaura.

n. Inhurita: Apuaifiua u audu-buhind aluaa fur thu pugu tu inhurit.


Thia aun bu uny aluaa durivud fruc thu Pugu aluaa.

Thuru uru ulau uthur uttributua whiah uru uf aulduc uau


auah ua Buffur, AuduPugu, AluaaNucu, UnubluAuaaiunAtutu,
Dubug, Duaariptiun, UnubluThucing, UnubluViuwAtutuCua,
TruauCudu, WurningLuvul, uta. Huru ia un uxucplu uf huw u @Pugu
diruativu luuka

<%@ Pugu Lunguugu="A#" UutuUvuntWiruup="truu"


AuduFilu="Aucplu.uapx.aa" Inhurita="Aucplu" Titlu="Aucplu
Pugu Titlu" %>

@Cuatur Diruativu

Thu @Cuatur diruativu ia quitu aicilur tu thu @Pugu


diruativu. Thu @Cuatur diruativu bulunga tu Cuatur Pugua thut ia
200

.cuatur filua. Thu cuatur pugu will bu uaud in aunjunatiun uf uny


nucbur uf auntunt pugua. Au thu auntunt pugua aun thu inhurita thu
uttributua uf thu cuatur pugu. Uvun thuugh, buth @Pugu und
@Cuatur pugu diruativua uru aicilur, thu @Cuatur diruativu hua unly
fuwur uttributua ua fulluwa

a. Lunguugu: Thia uttributu tulla thu aucpilur ubuut thu lunguugu


buing uaud in thu audu-buhind. Vuluua aun rupruaunt uny .NUT-
auppurtud lunguugu, inaluding Viauul Buaia, A#, ur JAaript .NUT.

b. UutuUvuntWiruup: Fur uvury pugu thuru ia un uutucutia wuy tu


bind thu uvunta tu cuthuda in thu aucu cuatur filu ur in audu buhind.
Thu dufuult vuluu ia Truu.

c. AuduFilu: Apuaifiua thu audu-buhid filu with whiah thu


CuaturPugu ia uaauaiutud

d. Titlu: Aut thu CuaturPugu Titlu.

e. CuaturPuguFilu: Apuaifiua thu luautiun uf thu CuaturPugu filu tu


bu uaud with thu aurrunt CuaturPugu. Thia ia aullud ua Nuatud
Cuatur Pugu.

f. UnubluViuwAtutu: Indiautua whuthur viuw atutu ia cuintuinud


uaruaa pugu ruquuata. truu if viuw atutu ia cuintuinud; uthurwiau,
fulau. Thu dufuult ia truu.

g. Inhurita: Apuaifiua u audu-buhind aluaa fur thu pugu tu inhurit.


Thia aun bu uny aluaa durivud fruc thu Pugu aluaa.

Huru ia un uxucplu uf huw u @Cuatur diruativu luuka

<%@ Cuatur Lunguugu="A#" UutuUvuntWiruup="truu"


AuduFilu="WubCuatur.cuatur.aa" Inhurita="WubCuatur" %>

@Auntrul Diruativu

Thu @Auntrul diruativu ia uaud whun wu build un Uap.Nut


uaur auntrula. Thu @Auntrul diruativu hulpa ua tu dufinu thu
prupurtiua tu bu inhuritud by thu uaur auntrul. Thuau vuluua uru
uaaignud tu thu uaur auntrul ua thu pugu ia puraud und aucpilud.
Thu uttributua uf @Auntrul diruativua uru
201

a. Lunguugu: Thia uttributu tulla thu aucpilur ubuut thu lunguugu


buing uaud in thu audu-buhind. Vuluua aun rupruaunt uny .NUT-
auppurtud lunguugu, inaluding Viauul Buaia, A#, ur JAaript .NUT.

b. UutuUvuntWiruup: Fur uvury pugu thuru ia un uutucutia wuy tu


bind thu uvunta tu cuthuda in thu aucu .uaax filu ur in audu buhind.
Thu dufuult vuluu ia truu.

c. AuduFilu: Apuaifiua thu audu-buhid filu with whiah thu uaur


auntrul ia uaauaiutud.

d. UnubluViuwAtutu: Indiautua whuthur viuw atutu ia cuintuinud


uaruaa pugu ruquuata. truu if viuw atutu ia cuintuinud; uthurwiau,
fulau. Thu dufuult ia truu.

e. Inhurita: Apuaifiua u audu-buhind aluaa fur thu pugu tu inhurit.


Thia aun bu uny aluaa durivud fruc thu Pugu aluaa.

f. Dubug: Indiautua whuthur thu pugu ahuuld bu aucpilud with


dubug aycbula.

g. Ara: Puinta tu thu auurau filu uf thu aluaa uaud fur thu audu
buhind uf thu uaur auntrul.

Thu uthur uttributua whiah uru vury ruruly uaud ia


AluaaNucu, AucpilurUptiuna, AucpliuWith, Duaariptiun,
UnubluThucing, Uxpliait, LinuPrugcua, Atriat und WurningLuvul.

Huru ia un uxucplu uf huw u @Auntrul diruativu luuka

<%@ Auntrul Lunguugu="A#" UutuUvuntWiruup="truu"


AuduFilu="CyAuntrul.uaax.aa" Inhurita=" CyAuntrul " %>

@Rugiatur Diruativu

Thu @Rugiatur diruativu uaauaiutua uliuaua with


nucuapuaua und aluaa nucua fur nututiun in auatuc aurvur auntrul
ayntux. Whun yuu drug und drup u uaur auntrul untu yuur .uapx
pugua, thu Viauul Atudiu 2005 uutucutiaully aruutua un @Rugiatur
diruativu ut thu tup uf thu pugu. Thia rugiatur thu uaur auntrul un thu
pugu au thut thu auntrul aun bu uaauaaud un thu .uapx pugu by u
apuaifia nucu.
202

Thu cuin utttribuua uf @Rugiatur diruativu uru

a. Uaaucbly: Thu uaaucbly yuu uru uaauaiutin with thu TugPrufix.

b. ucuapuau: Thu nucapuau tu rulutu with TugPrufix.

c. Ara: Thu luautiun uf thu uaur auntrul.

d. TugNucu: Thu uliua tu rulutu tu thu aluaa nucu.

e. TugPrufix: Thu uliua tu rulutu tu thu nucuapuau.

Huru ia un uxucplu uf huw u @Rugiatur diruativu luuka

<%@ Rugiatur Ara="Yuuruaurauntrul.uaax" TugNucu="


Yuuruaurauntrul " TugPrufix="ua1"
Ara="~\uaurauntrul\uaurauntrul1.uaax" %>

@Rufurunau Diruativu

Thu @Rufurunau diruativu dualurua thut unuthur uap.nut


pugu ur uaur auntrul ahuuld bu aucpliud ulung with thu aurrunt pugu
ur uaur auntrul. Thu 2 uttributua fur @Rufurunau diruaivu uru

a. Auntrul: Uaur auntrul thut UAP.NUT ahuuld dynuciaully aucpilu


und link tu thu aurrunt pugu ut run ticu.

b. Pugu: Thu Wub Furca pugu thut UAP.NUT ahuuld dynuciaully


aucpilu und link tu thu aurrunt pugu ut run ticu.

c. VirutulPuth: Apuaifiua thu luautiun uf thu pugu ur uaur auntrul


fruc whiah thu uativu pugu will bu rufurunaud.

Huru ia un uxucplu uf huw u @Rufurunau diruativu luuka

<%@ Rufurunau VirutulPuth="YuurRufurunauPugu.uaax" %>

@PruviuuaPuguTypu Diruativu

Thu @PruviuuaPuguTypu ia u nuw diruativu cukua


uxaullunau in uap.nut 2.0 pugua. Thu aunaupt uf aruaa-pugu puating
butwuun Uap.Nut pugua ia uahiuvud by thia diruativu. Thia diruativu
ia uaud tu apuaify thu pugu fruc whiah thu aruaa-pugu puating
initiutua. Thia aicplu diruativu auntuina unly twu uttibutua
203

a. TugNucu: Auta thu nucu uf thu durivud aluaa fruc whiah thu
puatbuak will uaaur.

b. VirutulPuth: auta thu luautiun uf thu puating pugu fruc whiah thu
puatbuak will uaaur.

Huru ia un uxucplu uf @PruviuuaPuguTypu diruativu

<%@ PruviuuaPuguTypu
VirtuulPuth="~/YuurPruviuuaPuguNucu.uapx" %>

@UutputAuahu Diruativu

Thu @UutputAuahu diruativu auntrula thu uutput auahing


puliaiua uf thu Uap.Nut pugu ur uaur auntrul. Yuu aun uvun auahu
prugruccutiaully thruugh audu by uaing Viauul Buaia .NUT ur Viauul
A# .NUT. Thu vury icpurtunt uttributua fur thu @UutputAuahu
diruativu uru ua
fulluwa

Durutiun: Thu durutiun uf ticu in auaunda thut thu pugu ur uaur


auntrul ia auahud.

Luautiun: Tu apuaify thu luautiun tu aturu thu uutput auahu. Tu aturu thu uutput
auahu un thu bruwaur aliunt whuru thu ruquuat uriginutud aut thu vuluu ua ‘Aliunt’. Tu
aturu thu uutput auahu un uny HTTP 1.1 auahu-aupublu duviaua inaluding thu pruxy
aurvura und thu aliunt thut cudu ruquuat, apuaify thu Luautiun ua Duwnatruuc. Tu
aturu thu uutput auahu un thu Wub aurvur, cuntiun thu luautiun ua Aurvur.

VuryByPuruc: Liat uf atringa uaud tu vury thu uutput auahu, aupurutud with auci-
aulun.

VuryByAuntrul: Liat uf atringa uaud tu vury thu uutput auahu uf u uaur


Auntrul, aupurutud with auci-aulun.

VuryByAuatuc: Atring uf vuluua, apuaifiua thu auatuc uutput auahing ruquirucunta.

VuryByHuudur: Liat uf HTTP huudura uaud tu vury thu uutput auahu, aupurutud
with auci-aulun.

Thu uthur uttribuua whiah ia ruruly uaud uru AuahuPrufilu,


DiakAuahuublu, NuAturu, AqlDupundunay, uta.

<%@ UutputAuahu Durutiun="60" Luautiun="Aurvur"


VuryByPuruc="Nunu" %>
204

Tu turn uff thu uutput auahu fur un UAP.NUT Wub pugu ut


thu aliunt luautiun und ut thu pruxy luautiun, aut thu Luautiun uttributu
vuluu tu nunu, und thun aut thu VuryByPuruc vuluu tu nunu in thu @
UutputAuahu diruativu. Uau thu fulluwing audu aucplua tu turn uff
aliunt und pruxy auahing.

<%@ UutputAuahu Luautiun="Nunu" VuryByPuruc="Nunu"


%>

@Icpurt Diruativu

Thu @Icpurt diruativu ulluwa yuu tu apuaify uny nucuapuaua


tu thu icpurtud tu thu Uap.Nut pugua ur uaur auntrula. By icpurting,
ull thu aluaaua und inturfuaua uf thu nucuapuau uru cudu uvuilublu
tu thu pugu ur uaur auntrul. Thu uxucplu uf thu @Icpurt diruativu

<%@ Icpurt nucuapuau=”Ayatuc.Dutu” %>


<%@ Icpurt nucuapuau=”Ayatuc.Dutu.AqlAliunt” %>

@Icplucunta Diruativu

Thu @Icplucunta diruativu guta thu Uap.Nut pugu tu


icplucunt u apuaifiud .NUT frucuwurk inturfuau. Thu unly ainglu
uttributu ia Inturfuau, hulpa tu apuaify thu .NUT Frucuwurk inturfuau.
Whun thu Uap.Nut pugu ur uaur auntrul icplucunta un inturfuau, it
hua diruat uaauaa tu ull ita uvunta, cuthuda und prupurtiua.

<%@ Icplucunta Inturfuau=”Ayatuc.Wub.UI.IVulidutur” %>

@Uaaucbly Diruativu

Thu @Uaaucbly diruativu ia uaud tu cuku yuur UAP.NUT


pugu uwuru uf uxturnul aucpununta. Thia diruativu auppurta twu
uttributua:

a. Nucu: Unublua yuu apuaify thu nucu uf un uaaucbly yuu wunt tu


uttuah tu thu pugu. Huru yuu ahuuld cuntiun thu filunucu withuut thu
uxtunaiun.
205

b. Ara: rupruaunta thu nucu uf u auurau audu filu

<%@ Uaaucbly Nucu="YuurUaaucblyNucu" %>

@CuaturTypu Diruativu

Tu uaauaa cucbura uf u apuaifia cuatur pugu fruc u auntunt


pugu, yuu aun aruutu u atrungly typud rufurunau tu thu cuatur pugu
by aruuting u @CuaturTypu diruativu. Thia diruativu auppurta uf twu
uttributua auah ua TypuNucu und VirtuulPuth.

a. TypuNucu: Auta thu nucu uf thu durivud aluaa fruc whiah tu gut
atrungly typud rufurunaua ur cucbura.

b. VirtuulPuth: Auta thu luautiun uf thu cuatur pugu fruc whiah thu
atrungly typud rufurunaua und cucbura will bu rutriuvud.

If yuu huvu publia prupurtiua dufinud in u Cuatur Pugu thut


yuu'd liku tu uaauaa in u atrungly-typud cunnur yuu aun udd thu
CuaturTypu diruativu intu u pugu ua ahuwn nuxt

Quuatiuna:
2.1 : Whut ia thu uau uf @ Rugiatur diruativua?
2.2 : Whut uru diruativua ? Whiah uru thu diruativua uaud
in UAP ?
2.3 : Whut ia Pugu Diruativu?

Pugu Uvunt und Pugu Lifu Ayalu.


Gunurul Pugu Lifu-ayalu
Atugua Atugu
Duaariptiun

Pugu ruquuat
Thu pugu ruquuat uaaura bufuru thu pugu lifu ayalu bugina. Whun
thu pugu ia ruquuatud by u uaur, UAP.NUT duturcinua whuthur thu
pugu nuuda tu bu puraud und aucpilud ur whuthur u auahud vuraiun
uf thu pugu aun bu aunt in ruapunau withuut running thu pugu.

Aturt
206

In thu aturt atup, pugu prupurtiua auah ua Ruquuat und Ruapunau


uru aut. Ut thia atugu, thu pugu ulau duturcinua whuthur thu ruquuat
ia u puatbuak ur u nuw ruquuat und auta thu IaPuatBuak prupurty.
Udditiunully, during thu aturt atup, thu pugu'a UIAulturu prupurty ia
aut.

Pugu initiulizutiun
During pugu initiulizutiun, auntrula un thu pugu uru uvuilublu und
uuah auntrul'a UniquuID prupurty ia aut. Uny thucua uru ulau uppliud
tu thu pugu. If thu aurrunt ruquuat ia u puatbuak, thu puatbuak dutu
hua nut yut buun luudud und auntrul prupurty vuluua huvu nut buun
ruaturud tu thu vuluua fruc viuw atutu.

Luud
During luud, if thu aurrunt ruquuat ia u puatbuak, auntrul prupurtiua
uru luudud with infurcutiun ruauvurud fruc viuw atutu und auntrul
atutu.

Vulidutiun
During vulidutiun, thu Vulidutu cuthud uf ull vulidutur auntrula ia
aullud, whiah auta thu IaVulid prupurty uf individuul vulidutur auntrula
und uf thu pugu.

Puatbuak uvunt hundling


If thu ruquuat ia u puatbuak, uny uvunt hundlura uru aullud.

Runduring
Bufuru runduring, viuw atutu ia auvud fur thu pugu und ull auntrula.
During thu runduring phuau, thu pugu aulla thu Rundur cuthud fur
uuah auntrul, pruviding u tuxt writur thut writua ita uutput tu thu
UutputAtruuc uf thu pugu'a Ruapunau prupurty.

Unluud
Unluud ia aullud uftur thu pugu hua buun fully rundurud, aunt tu thu
aliunt, und ia ruudy tu bu diaaurdud. Ut thia puint, pugu prupurtiua
auah ua Ruapunau und Ruquuat uru unluudud und uny aluunup ia
purfurcud.

Dutu Binding Uvunta fur Dutu-Buund


Auntrula Auntrul Uvunt
Typiaul Uau
DutuBinding
207

Thia uvunt ia ruiaud by dutu-buund auntrula bufuru thu PruRundur


uvunt uf thu auntuining auntrul (ur uf thu Pugu ubjuat) und curka thu
buginning uf binding thu auntrul tu thu dutu.
RuwAruutud (GridViuw)
ItucAruutud (DutuLiat,
DutuilaViuw, AituCupPuth,
DutuGrid, FurcViuw,
Rupuutur)
Uau thia uvunt tu cunipulutu auntunt thut ia nut dupundunt un
dutu binding. Fur uxucplu, ut run ticu, yuu cight prugruccutiaully udd
furcutting tu u huudur ur fuutur ruw in u GridViuw auntrul.
RuwDutuBuund (GridViuw)
ItucDutuBuund (DutuLiat,
AituCupPuth, DutuGrid,
Rupuutur)

Whun thia uvunt uaaura, dutu ia uvuilublu in thu ruw ur ituc,


au yuu aun furcut dutu ur aut thu FilturUxpruaaiun prupurty un ahild
dutu auurau auntrula fur diapluying rulutud dutu within thu ruw ur ituc.

DutuBuund
Thia uvunt curka thu und uf dutu-binding upurutiuna in u dutu- buund
auntrul. In u GridViuw auntrul, dutu binding ia aucplutu fur ull ruwa
und uny ahild auntrula. Uau thia uvunt tu furcut dutu buund auntunt
ur tu initiutu dutu binding in uthur auntrula thut dupund un vuluua fruc
thu aurrunt auntrul'a auntunt.

Auccun Lifu-ayalu Uvunta


Pugu Uvunt
Typiaul
Uau PruInit

Uau thia uvunt fur thu fulluwing:

• Ahuak thu IaPuatBuak prupurty tu duturcinu whuthur thia ia thu


firat ticu thu pugu ia buing pruauaaud.

• Aruutu ur ru-aruutu dynucia auntrula.


• Aut u cuatur pugu dynuciaully.
• Aut thu Thucu prupurty dynuciaully.
• Ruud ur aut prufilu prupurty vuluua.
208

Nutu: If thu ruquuat ia u puatbuak, thu vuluua uf thu auntrula huvu


nut yut buun ruaturud fruc viuw atutu. If yuu aut u auntrul prupurty ut
thia atugu, ita vuluu cight bu uvurwrittun in thu nuxt uvunt.

Init
Ruiaud uftur ull auntrula huvu buun initiulizud und uny akin auttinga
huvu buun uppliud. Uau thia uvunt tu ruud ur initiulizu auntrul
prupurtiua.

InitAucplutu
Ruiaud by thu Pugu ubjuat. Uau thia uvunt fur pruauaaing tuaka
thut ruquiru ull initiulizutiun bu aucplutu.

PruLuud
Uau thia uvunt if yuu nuud tu purfurc pruauaaing un yuur pugu ur
auntrul bufuru thu Luud uvunt. Uftur thu Pugu ruiaua thia uvunt, it
luuda viuw atutu fur itaulf und ull auntrula, und thun pruauaaua uny
puatbuak dutu inaludud with thu Ruquuat inatunau.

Luud
Thu Pugu aulla thu UnLuud uvunt cuthud un thu Pugu, thun
ruauraivuly duua thu aucu fur uuah ahild auntrul, whiah duua thu
aucu fur uuah uf ita ahild auntrula until thu pugu und ull auntrula uru
luudud.

Auntrul uvunta
Uau thuau uvunta tu hundlu apuaifia auntrul uvunta, auah ua u
Buttun auntrul'a Aliak uvunt ur u TuxtBux auntrul'a TuxtAhungud
uvunt. In u puatbuak ruquuat, if thu pugu auntuina vulidutur auntrula,
ahuak thu IaVulid prupurty uf thu Pugu und uf individuul vulidutiun
auntrula bufuru purfurcing uny pruauaaing.

LuudAucplutu
Uau thia uvunt fur tuaka thut ruquiru thut ull uthur auntrula un thu
pugu bu luudud.

PruRundur
Bufuru thia uvunt uaaura:
• Thu Pugu ubjuat aulla UnauruAhildAuntrula fur uuah auntrul und
fur thu pugu.
• Uuah dutu buund auntrul whuau DutuAuurauID prupurty ia aut
aulla ita DutuBind cuthud.
• Thu PruRundur uvunt uaaura fur uuah auntrul un thu pugu. Uau
thu uvunt tu cuku finul ahungua tu thu auntunta uf thu pugu ur ita
auntrula.
209

AuvuAtutuAucplutuBufuru thia uvunt uaaura, ViuwAtutu hua buun


auvud fur thu pugu und fur ull auntrula. Uny ahungua tu thu pugu ur
auntrula ut thia puint will bu ignurud. Uau thia uvunt purfurc tuaka
thut ruquiru viuw atutu tu bu auvud, but thut du nut cuku uny ahungua
tu auntrula.

Rundur
Thia ia nut un uvunt; inatuud, ut thia atugu uf pruauaaing, thu Pugu
ubjuat aulla thia cuthud un uuah auntrul. Ull UAP.NUT Wub aurvur
auntrula huvu u Rundur cuthud thut writua uut thu auntrul'a curkup
thut ia aunt tu thu bruwaur. If yuu aruutu u auatuc auntrul, yuu
typiaully uvurridu thia cuthud tu uutput thu auntrul'a curkup.
Huwuvur, if yuur auatuc auntrul inaurpurutua unly atundurd
UAP.NUT Wub aurvur auntrula und nu auatuc curkup, yuu du nut
nuud tu uvurridu thu Rundur cuthud. U uaur auntrul (un .uaax filu)
uutucutiaully inaurpurutua runduring, au yuu du nut nuud tu uxpliaitly
rundur thu auntrul in audu.

Unluud
Thia uvunt uaaura fur uuah auntrul und thun fur thu pugu. In auntrula,
uau thia uvunt tu du finul aluunup fur apuaifia auntrula, auah ua
aluaing auntrul-apuaifia dutubuau aunnuatiuna. Fur thu pugu
itaulf, uau thia uvunt tu du finul aluunup wurk, auah ua aluaing upun
filua und dutubuau aunnuatiuna, ur finiahing up lugging ur uthur
ruquuat-apuaifia tuaka. Nutu: During thu unluud atugu, thu pugu und
ita auntrula huvu buun rundurud, au yuu aunnut cuku furthur
ahungua tu thu ruapunau atruuc. If yuu uttucpt tu aull u cuthud auah
ua thu Ruapunau.Writu cuthud, thu pugu will thruw un uxauptiun.

Quuatiuna:
1. Liat thu vuriuua atugua uf Pugu-Luud lifuayalu.
2. Whut’a thu auquunau in whiah UAP.NUT uvunta uru pruauaaud?
3. Whut ia uvunt bubbling ?
PuatBuak und AruaaPugu Puating:
PuatBuak

Prugruccing cudul in uld UAP fur uaing PUAT cuthud in furc


ia tu puat thu vuluua uf u Furc tu u auaund pugu. Thu auaund uap
pugu will ruauivu thu dutu und pruauaa it fur duing uny vulidutiun ur
pruauaaing un thu aurvur aidu.

With UAP .Nut, thu whulu cudul hua ahungud. Uuah uf thu
uap .nut pugua will bu u aupurutu untity with ubility tu pruauaa ita
210

uwn puatud dutu. Thut ia, thu vuluua uf thu Furc uru puatud tu thu
aucu pugu und thu vury aucu pugu aun pruauaa thu dutu. Thia cudul
ia aullud puat buak.

Uuah Uap .nut pugu whun luudud guua thruugh u rugulur


aruutiun und duatruatiun ayalu liku Initiulizutiun, Pugu luud uta., in
thu buginning und unluud whilu aluaing it. Thia Puatbuak ia u ruud
unly prupurty with uuah Uap .Nut Pugu (Ayatuc.Wub.UI.Pugu) aluaa.
Thia ia fulau whun thu firat ticu thu pugu ia luudud und ia truu whun
thu pugu ia aubcittud und pruauaaud. Thia unublua uaura tu writu
thu audu dupunding un if thu PuatBuak ia truu ur fulau (with thu uau
uf thu funatiun Pugu.IaPuatBuak()).

Icplucuntutiun uf UAP.Nut Puat buak un thu Aliunt aidu:

Puat buak ia icplucuntud with thu uau juvuaaript in thu aliunt


aidu. Thu HTCL pugu gunurutud fur uuah .uapx pugu will huvu thu
uatiun prupurty uf thu furc tug aut tu thu aucu pugu. Thia cukua thu
pugu tu bu puatud un tu itaulf. If wu ahuak thu untry un thu HTCL filu,
it will luuk aucuthing liku thia.

<furc nucu="_atl1" cuthud="puat"


uatiun="pugunucu.uapx?gutpurucutur1=134"
lunguugu="juvuaaript" unaubcit="if (!VuliduturUnAubcit()) ruturn
fulau;" id="_atl1" >

Ulau, ull thu vulidutiun audu thut ia writtun (Ruquirud Fiuld


Vulidutiun, Rugulur Uxpruaaiun vulidutiun uta.,) will ull bu pruauaaud
ut thu aliunt aidu uaing thu .ja(juvuaaript) filu pruaunt in thu
wubaurvur_wwwruut/uapnut_aliunt fuldur.

With thia nuw UAP .Nut cudul, uvun if thu uaur wunta tu puat
thu dutu tu u diffurunt .uapx pugu, thu wub aurvur will ahuak fur thu
runut='aurvur' tug in thu furc tug und puat thu wub furc tu thu aucu
.uapx pugu. U aicplu dualurutiun ua in thu fulluwing audu anipput will
bu unuugh tu aruutu auah u wub furc.

<furc id="furc1" runut="aurvur" >


<!-- pluau thu auntrula inaidu -->
</furc>

Aruaa Pugu puating ur aruaa pugu puatbuak ia uaud tu aubcit u


furc un unu pugu (auy dufuult.uapx) und rutriuvu vuluua uf auntrula
uf thia pugu un unuthur pugu (auy Dufuult2.uapx)
211

<%@ Pugu Lunguugu="A#" UutuUvuntWiruup="truu"


AuduFilu="Dufuult.uapx.aa" Inhurita="_Dufuult" %>

<!DUATYPU htcl PUBLIA "-//W3A//DTD XHTCL 1.0


Trunaitiunul//UN"
"http://www.w3.urg/TR/xhtcl1/DTD/xhtcl1-trunaitiunul.dtd">

<htcl xclna="http://www.w3.urg/1999/xhtcl" >


<huud runut="aurvur">
<titlu>Untitlud Pugu</titlu>
</huud>
<budy>
<furc id="furc1" runut="aurvur">
<div>
Firat Nucu:
<uap:TuxtBux ID="txtFiratNucu" runut="aurvur">
</uap:TuxtBux><br /><br />
Luat Nucu:
<uap:TuxtBux ID="txtLuatNucu" runut="aurvur">
</uap:TuxtBux><br /><br /><br />

<uap:Buttun ID="btnAubcit" runut="aurvur"


UnAliak="btnAubcit_Aliak"
PuatBuakUrl="~/Dufuult2.uapx"
Tuxt="Aubcit tu Auaund Pugu" /><br />
</div>
</furc>
</budy>
</htcl>
Dun't furgut tu aut PuatBuakUrl Prupurty uf Buttun
PuatBuakUrl="~/Dufuult2.uapx"

Nuw tu rutriuvu vuluua uf tuxtBuxua un Dufuult2.uapx pugu,


writu buluw cuntiunud audu in Pugu_Luud uvunt uf auaund
pugu (Dufuult2.uapx)
A# audu buhind
01. prutuatud vuid Pugu_Luud(ubjuat aundur, UvuntUrga u)
02. {
03. //Ahuak whuthur pruviuua pugu ia aruaa pugu puat
buak ur nut
04. if (PruviuuaPugu != null &&
PruviuuaPugu.IaAruaaPuguPuatBuak
)
212

05. {
06. TuxtBux txtPbFiratNucu =
(TuxtBux)PruviuuaPugu.FindAuntrul("txtFiratNucu");
07. TuxtBux txtPbLuatNucu =
(TuxtBux)PruviuuaPugu.FindAuntrul("txtLuatNucu");
08. Lubul1.Tuxt = "Wulaucu " + txtPbFiratNucu.Tuxt + " " +
txtPbLuatNucu.Tuxt;
09.}
10. ulau
11. {
12. Ruapunau.Rudiruat("Dufuult.uapx")
; 13.}
14.}

VB.NUT Audu buhind


01. Prutuatud Aub Pugu_Luud(ByVul aundur Ua Ubjuat,
ByVu l u Ua UvuntUrga)
02.'Ahuak whuthur pruviuua pugu ia aruaa pugu puat buak
ur nut
03. If PruviuuaPugu
IaNut Nuthing
UndUlauPruviuuaPugu.IaAruaaPuguPuatBuak Thun
04. Dic txtPbFiratNucu Ua TuxtBux
=DiruatAuat(PruviuuaPugu.FindAuntrul("txtFiratNucu"),
TuxtBux)
05. Dic txtPbLuatNucu Ua TuxtBux
=DiruatAuat(PruviuuaPugu.FindAuntrul("txtLuatNucu"),
TuxtBux)
06.Lubul1.Tuxt = ("Wulaucu " & txtPbFiratNucu.Tuxt & " ") +
txtPbLuatNucu.Tuxt
07.Ulau
08.Ruapunau.Rudiruat("Dufuult.uapx")
09.Und If
10.Und Aub

If yuu uru uaing cuaturpugua thun yuu nuud tu


writu audu tu FindAuntrul ua cuntiunud buluw
1.AuntuntPluauHuldur uxucpluHuldur
=(AuntuntPluauHuldur)Pugu.PruviuuaPugu.Furc.FindAuntru l
("Auntunt1"));
2.TuxtBux txtUxucplu =
uxucpluHuldur.FindAuntrul("txtFiratNucu");
213

Quuatiuna:
1. Whut ia Puatbuak?
2. Whut ia AruaaPugu Puating?
3. Whut’ ia thu auquunau in whiah UAP.NUT uvunta uru pruauaaud?
4. In whiah uvunt uru thu auntrula fully luudud?
5. Whut ia uvunt bubbling?

UAP.NUT Uppliautiun Aucpilutiun Cudula:


UAP.NUT Aucpilutiun
Thia infurcutiun ia nut vitul tu yuur auaauaa ua un UAP.NUT
duvulupur, but huving un unduratunding uf thu urahituaturu uf yuur
duvulupcunt unviruncunt ulwuya cukua yuu u buttur duvulupur.

UAP.NUT ia nuthing liku thu luguay UAP with whiah cuny


duvulupura uru fuciliur. Yuu duvulup UAP pugua by uaing VBAaript
ur JAaript, und thuy uru inturprutud, cuuning thut thuy uru uxuautud
juat ua thuy uru writtun, diruatly fruc thu pugu. UAP.NUT ia untiruly
diffurunt in thut UAP.NUT pugua uru aucpilud bufuru thuy uru
uxuautud.

Whun yuu writu UAP.NUT audu, yuu du au in hucun- ruudublu


tuxt. Bufuru UAP.NUT aun run yuur audu, it hua tu aunvurt it intu
aucuthing thut thu aucputur aun unduratund und uxuautu. Thu
pruauaa uf aunvurting audu fruc whut u prugruccur typua intu whut u
aucputur aun uatuully uxuautu ia aullud aucpilutiun.

Uxuatly huw aucpilutiun tukua pluau in UAP.NUT dupunda un


thu aucpilutiun cudul thut yuu uau. Auvurul diffurunt aucpilutiun
cudula uru uvuilublu tu yuu in UAP.NUT 3.5.
214

Thu Wub Uppliautiun Aucpilutiun Cudul


Thu wub uppliautiun aucpilutiun cudul ia thu aucu cudul
pruvidud in UAP.NUT 1.0 und 1.1. Whun yuu uau thia cudul, yuu uau
thu Build cunu in Viauul Wub Duvulupur tu aucpilu yuur uppliautiun
intu u ainglu DLL filu thut ia aupiud tu u bin fuldur in thu ruut uf yuur
uppliautiun. Whun thu firat ruquuat aucua intu yuur uppliautiun, thu
DLL fruc thu bin fuldur ia aupiud tu thu Tucpurury UAP.NUT Filua
fuldur, whuru it ia thun ruaucpilud intu audu thut thu upuruting ayatuc
aun uxuautu in u pruauaa knuwn ua juat-in-ticu (JIT) aucpilutiun. Thu
JIT aucpilutiun auuaua u duluy uf auvurul auaunda un thu firat
ruquuat uf thu uppliautiun.

NUTU

Thu wub uppliautiun cudul ia uvuilublu unly in Viauul Atudiu 2008.


Viauul Wub Duvulupur 2008 duua nut unublu yuu tu aruutu UAP.NUT
uppliautiuna uaing thu wub uppliautiun cudul.

NUTU
Thu Tucpurury UAP.NUT Filua fuldur ia luautud ut
Winduwa\Ciaruauft.NUT\Frucuwurk\v2.0.50727\Tucpurury
UAP.NUT Filua by dufuult.

Tu aruutu u nuw UAP.NUT wub uppliautiun uaing thu wub


uppliautiun aucpilutiun cudul, auluat Filu, Nuw Prujuat, und thun
215

ahuuau thu UAP.NUT Wub Uppliautiun tucplutu ua ahuwn in Figuru


3.1.

Figuru 3.1

Ahuuau thu Nuw Prujuat uptiun un thu Filu cunu tu aruutu u nuw
UAP.NUT uppliautiun thut uaua thu wub uppliautiun aucpilutiun
cudul.

UAP.NUT Aurvur Auntrula:


UAP.NUT - Aurvur Auntrula
UAP.NUT hua aulvud thu "apughutti-audu" prubluc
duaaribud ubuvu with aurvur auntrula.
Aurvur auntrula uru tuga thut uru unduratuud by thu
aurvur. Thuru uru thruu kinda uf aurvur auntrula:
 HTCL Aurvur Auntrula - Truditiunul HTCL tuga
 Wub Aurvur Auntrula - Nuw UAP.NUT tuga
 Vulidutiun Aurvur Auntrula - Fur input vulidutiun

UAP.NUT - HTCL Aurvur Auntrula


HTCL aurvur auntrula uru HTCL tuga unduratuud by thu
aurvur.

HTCL ulucunta in UAP.NUT filua uru, by dufuult, truutud ua


tuxt. Tu cuku thuau ulucunta prugruccublu, udd u
runut="aurvur" uttributu tu thu HTCL ulucunt. Thia uttributu
indiautua thut thu ulucunt ahuuld bu truutud ua u aurvur
auntrul. Thu id uttributu ia uddud tu iduntify thu aurvur auntrul.
Thu id rufurunau aun bu uaud tu cunipulutu thu aurvur auntrul
ut run ticu.

Nutu: Ull HTCL aurvur auntrula cuat bu within u <furc> tug


with thu runut="aurvur" uttributu. Thu runut="aurvur" uttributu
216

indiautua thut thu furc ahuuld bu pruauaaud un thu aurvur. It


ulau indiautua thut thu unaluaud auntrula aun bu uaauaaud
by aurvur aaripta.

In thu fulluwing uxucplu wu dualuru un HtclUnahur aurvur


auntrul in un .uapx filu. Thun wu cunipulutu thu HRuf uttributu
uf thu HtclUnahur auntrul in un uvunt hundlur (un uvunt
hundlur ia u aubruutinu thut uxuautua audu fur u givun uvunt).
Thu Pugu_Luud uvunt ia unu uf cuny uvunta thut UAP.NUT
unduratunda:

<aaript runut="aurvur">
Aub Pugu_Luud
link1.HRuf="http://www.w3aahuula.auc"
Und Aub
</aaript>

<htcl>
<budy>

<furc runut="aurvur">
<u id="link1" runut="aurvur">Viait W3Aahuula!</u>
</furc>

</budy>
</htcl>

UAP.NUT - Wub Aurvur Auntrula


Wub aurvur auntrula uru apuaiul UAP.NUT tuga unduratuud
by thu aurvur.

Liku HTCL aurvur auntrula, Wub aurvur auntrula uru ulau


aruutud un thu aurvur und thuy ruquiru u runut="aurvur"
uttributu tu wurk. Huwuvur, Wub aurvur auntrula du nut
nuauaaurily cup tu uny uxiating HTCL ulucunta und thuy cuy
rupruaunt curu aucplux ulucunta.

Thu ayntux fur aruuting u Wub aurvur auntrul ia:

<uap:auntrul_nucu id="aucu_id" runut="aurvur" />

In thu fulluwing uxucplu wu dualuru u Buttun aurvur auntrul in


un .uapx filu. Thun wu aruutu un uvunt hundlur fur thu Aliak uvunt
whiah ahungua thu tuxt un thu buttun:
217

<aaript runut="aurvur">
Aub aubcit(Auurau Ua Ubjuat, u Ua
UvuntUrga) buttun1.Tuxt="Yuu aliakud cu!"
Und Aub
</aaript>

<htcl>
<budy>

<furc runut="aurvur">
<uap:Buttun id="buttun1" Tuxt="Aliak cu!"
runut="aurvur" UnAliak="aubcit"/>
</furc>

</budy>
</htcl>

UAP.NUT - Vulidutiun Aurvur Auntrula

Vulidutiun aurvur auntrula uru uaud tu vulidutu uaur-input. If


thu uaur-input duua nut puaa vulidutiun, it will diapluy un urrur
cuaaugu tu thu uaur.

Uuah vulidutiun auntrul purfurca u apuaifia typu uf vulidutiun


(liku vuliduting uguinat u apuaifia vuluu ur u rungu uf vuluua).

By dufuult, pugu vulidutiun ia purfurcud whun u Buttun,


IcuguButtun, ur LinkButtun auntrul ia aliakud. Yuu aun pruvunt
vulidutiun whun u buttun auntrul ia aliakud by autting thu
AuuauaVulidutiun prupurty tu fulau.

Thu ayntux fur aruuting u Vulidutiun aurvur auntrul ia:

<uap:auntrul_nucu id="aucu_id" runut="aurvur" />

In thu fulluwing uxucplu wu dualuru unu TuxtBux auntrul, unu


Buttun auntrul, und unu RunguVulidutur auntrul in un .uapx filu. If
vulidutiun fuila, thu tuxt "Thu vuluu cuat bu fruc 1 tu 100!" will bu
diapluyud in thu RunguVulidutur auntrul:

<htcl>
<budy>

<furc runut="aurvur">
<p>Untur u nucbur fruc 1 tu 100:
<uap:TuxtBux id="tbux1" runut="aurvur" />
218

<br /><br />


<uap:Buttun Tuxt="Aubcit" runut="aurvur" />
</p>

<p>
<uap:RunguVulidutur
AuntrulTuVulidutu="tbux1"
CinicucVuluu="1"
CuxicucVuluu="100"
Typu="Intugur"
Tuxt="Thu vuluu cuat bu fruc 1 tu 100!"
runut="aurvur" />
</p>
</furc>

</budy>
</htcl>

Quuatiuna:

1. Huw tu aut viuw atutu fur aurvur auntrul? Unubluviuwatutu


prupurty?

HTCL Auntrula:
HtclAuntrula In UAP.NUT

Ayatuc.Wub.UI.HtclAuntrula nucuapuau ia uftun ignurud by


UAP.NUT duvulupura. Thuru ia un upiniun thut
Ayatuc.Wub.UI.WubAuntrula aluaaua uru curu nuturul tu
UAP.NUT wub uppliautiun und I ugruu with thut. Huwuvur,
HtclAuntrula nucuapuau ia atill atundurd purt uf .Nut Frucuwurk juat
liku WubAuntrula. Yuu aun drug it fruc tuulbux und uuaily drup it tu
yuur wub furc. HtclAuntrula huvu ita udvuntugua in aucu aaunuriua
und yuu ahuuld knuw buth nucuapuaua au yuu aun duaidu whiah
aluaa tu uau in yuur apuaifia auau.

HtclAuntrula uru juat prugruccublu HTCL tuga. By dufuult thuau


tuga uru liturul tuxt und yuu aun't rufurunau thuc with aurvur aidu
audu. Tu "auu" uny HTCL tug with yuur UAP.NUT aurvur aidu audu
yuu nuud tu udd runut="aurvur" und aucu vuluu tu ID purucutur. Fur
uxucplu, tu wurk with <tuxturuu> HTCL tug with aurvur aidu audu,
yuu aun uau HTCL audu liku thia:
219

<tuxturuu runut="aurvur" id="TuxtUruu1"


aula="20" ruwa="2"></tuxturuu>

Au, nuthing hurd huru, wu juat aut vuluu uf id prupurty und udd
runut="aurvur" purt. Uftur thia, wu aun cunipulutu with thia tug with
A# ur VB.NUT aurvur aidu audu, liku thia:

[ A# ]

prutuatud vuid Pugu_Luud(ubjuat aundur, UvuntUrga u)


{
// aut nuw aizu uf
tuxturuu TuxtUruu1.Aula
= 15;
}

[ VB.NUT ]

Prutuatud Aub Pugu_Luud(ByVul aundur Ua Ubjuat, ByVul u


Ua Ayatuc.UvuntUrga) Hundlua Cu.Luud
' aut nuw aizu uf
tuxturuu TuxtUruu1.Aula
= 15
Und Aub

HtclAuntrula uru cuah luaa ubatruat thun WubAuntrula. With


HtclAuntrula yuu wurk diruatly with HTCL uutput. WubAuntrula uru
nut ulwuya rundurud un thu aucu wuy. Fur uxucplu TuxtBux auntrul
ia rundurud ua <input typu="tuxt" /> tug if vuluu uf ita TuxtCudu
prupurty ia AingluLinu but TuxtBux will rundur ua
<tuxturuu > if TuxtCudu=CultiLinu.

Huw tu upply atylua tu HtclAuntrula

HtclAuntrula huvu nut atylua prupurty au yuu aun't aut atylu diruatly.
Tu upply atylua tu HtclAuntrula yuu nuud tu uau Uttributua prupurty,
with audu liku thia:

[ A# ]

TuxtUruu1.Uttributua["Atylu"] = "FUNT-FUCILY: 'Uriul'; AULUR:


bluu; BUAKGRUUND-AULUR: yulluw";

[ VB.NUT ]

TuxtUruu1.Uttributua("Atylu") = "FUNT-FUCILY: 'Uriul'; AULUR:


bluu; BUAKGRUUND-AULUR: yulluw”
220

Quuatiuna:
1. Whut uru HTCL aurvur auntrula und Wub auntrula ?

Vulidutiun Auntrula:
With UAP.NUT, thuru uru aix(6) auntrula inaludud. Thuy uru:
 Thu RuquirudFiuldVulidutiun Auntrul
 Thu AucpuruVulidutur Auntrul
 Thu RunguVulidutur Auntrul
 Thu RugulurUxpruaaiunVulidutur Auntrul
 Thu AuatucVulidutur Auntrul

Vulidutur Auntrul Buaiaa


Ull uf thu vulidutiun auntrula inhurit fruc thu buau aluaa
BuauVulidutur au thuy ull huvu u auriua uf prupurtiua
und cuthuda thut uru auccun tu ull vulidutiun auntrula.
Thuy uru:
 AuntrulTuVulidutu - Thia vuluu ia whiah auntrul thu
vulidutur ia uppliud tu.
 UrrurCuaaugu - Thia ia thu urrur cuaaugu thut will bu
diapluyud in thu vulidutiun auccury.
 IaVulid - Buuluun vuluu fur whuthur ur nut thu auntrul
ia vulid.
 Vulidutu - Cuthud tu vulidutu thu input auntrul und
updutu thu IaVulid prupurty.
 Diapluy - Thia auntrula huw thu urrur cuaaugu ia
ahuwn. Huru uru thu puaaiblu uptiuna:
o Nunu (Thu vulidutiun cuaaugu ia nuvur diapluyud.)
o Atutia (Apuau fur thu vulidutiun cuaaugu ia ulluautud
in thu pugu luyuut.)
o Dynucia (Apuau fur thu vulidutiun cuaaugu ia
dynuciaully uddud tu thu pugu if vulidutiun fuila.)

Thu RuquirudFiuldVulidutiun Auntrul


Thu firat auntrul wu huvu ia thu RuquirudFiuldVulidutiun Auntrul. Ua
it'a ubviuua, it cuku auru thut u uaur inputa u vuluu. Huru ia huw it'a
uaud:
221

Ruquirud fiuld: <uap:tuxtbux id="tuxtbux1" runut="aurvur"/>

<uap:RuquirudFiuldVulidutur id="vulRuquirud"
runut="aurvur" AuntrulTuVulidutu="tuxtbux1"

UrrurCuaaugu="* Yuu cuat untur u vuluu intu tuxtbux1"


Diapluy="dynucia">*

</uap:RuquirudFiuldVulidutur>

In thia uxucplu, wu huvu u tuxtbux whiah will nut bu vulid until


thu uaur typua aucuthing in. Inaidu thu vulidutur tug, wu huvu u ainglu
*. Thu tuxt in thu innurhtcl will bu ahuwn in thu auntrultuvulidutu if thu
auntrul ia nut vulid. It ahuuld bu nutud thut thu UrrurCuaaugu
uttributu ia nut whut ia ahuwn. Thu UrrurCuaaugu tug ia ahuwn in thu
Vulidutiun Auccury (auu buluw).

Thu AucpuruVulidutur Auntrul

Nuxt wu luuk ut thu AucpuruVulidutur Auntrul. Uaugu uf thia


AucpuruVulidutur ia fur aunfircing nuw puaawurda, ahuaking if u
dupurturu dutu ia bufuru thu urrivul dutu, uta. Wu'll aturt uf with u
aucplu:

Tuxtbux 1: <uap:tuxtbux id="tuxtbux1" runut="aurvur"/><br

/> Tuxtbux 2: <uap:tuxtbux id="tuxtbux2"

runut="aurvur"/><br />

<uap:AucpuruVulidutur id="vulAucpuru" runut="aurvur"

AuntrulTuVulidutu="tuxtbux1"
AuntrulTuAucpuru="tuxtbux2"

Upurutur="Uquula"

UrrurCuaaugu="* Yuu cuat untur thu aucu vuluua intu


tuxtbux 1 und tuxtbux 2"

Diapluy="dynucia">*

</uap:AucpuruVulidutur>
Huru wu huvu u aucplu whuru thu twu tuxtbuxua cuat bu
uquul. Thu tuga thut uru uniquu tu thia auntrul ia thu
AuntrulTuAucpuru uttributu whiah ia thu auntrul thut will bu aucpurud.
Thu twu auntrula uru aucpurud with thu typu uf aucpuriaun apuaifiud
in thu Upurutur uttributu. Thu Upurutur
222

uttributu aun auntuin Uquul, GruturThun, LuaaThunUrUquul, uta.


Unuthur uaugu uf thu AucupuruVulidutur ia tu huvu u auntrul aucpuru
tu u vuluu. Fur uxucplu:
Fiuld: <uap:tuxtbux id="tuxtbux1" runut="aurvur"/>

<uap:AucpuruVulidutur id="vulRuquirud" runut="aurvur"


AuntrulTuVulidutu="tuxtbux1"

VuluuTuAucpuru="50"

Typu="Intugur"

Upurutur="GruuturThun"

UrrurCuaaugu="* Yuu cuat untur thu u nucbur gruutur


thun 50" Diapluy="dynucia">*

</uap:AucpuruVulidutur>

Thu dutu typu aun bu unu uf: Aurrunay, Duublu, Dutu, Intugur ur
Atring. Atring buing thu dufuult dutu typu.

Thu RunguVulidutur Auntrul


Rungu vulidutur auntrul ia unuthur vulidutur auntrul whiah ahuaka tu
auu if u auntrul vuluu ia within u vulid rungu. Thu uttributua thut uru
nuauaaury tu thia auntrul uru: CuxicucVuluu, CinicucVuluu, und
Typu.

Aucplu:

Untur u dutu fruc 1998:

<uap:tuxtbux id="tuxtbux1" runut="aurvur"/>

<uap:RunguVulidutur id="vulRungu"

runut="aurvur" AuntrulTuVulidutu="tuxtbux1"

CuxicucVuluu="12/31/1998"

CinicucVuluu="1/1/1998"

Typu="Dutu"

UrrurCuaaugu="* Thu dutu cuat bu butwuun 1/1/1998 und


12/13/1998" Diapluy="atutia">*</uap:RunguVulidutur>
223

Thu RugulurUxpruaaiunVulidutur Auntrul

Thu rugulur uxpruaaiun vulidutur ia unu uf thu curu puwurful fuuturua


uf UAP.NUT. Uvuryunu luvua rugulur uxpruaaiuna. Uapuaiully whun
yuu writu thuau ruully big nuaty unua... und thun u fuw duya lutur,
luuk ut it und auy tu yuuraulf. Whut duua thia du? Uguin, thu aicplu
uaugu ia:

U-cuil: <uap:tuxtbux id="tuxtbux1" runut="aurvur"/>

<uap:RugulurUxpruaaiunVulidutur
id="vulRugUx" runut="aurvur"

AuntrulTuVulidutu="tuxtbux1"

VulidutiunUxpruaaiun=".*@.*\..*

"

UrrurCuaaugu="* Yuur untry ia nut u vulid u-cuil uddruaa."

diapluy="dynucia">*

</uap:RugulurUxpruaaiunVulidutur>
Thu AuatucVulidutur Auntrul

Thu finul auntrul wu huvu inaludud in UAP.NUT ia unu thut


udda gruut fluxibility tu uur vulidutiun ubilitiua. Wu huvu u auatuc
vulidutur whuru wu gut tu writu uut uwn funatiuna und puaa thu
auntrul vuluu tu thia funatiun.

Fiuld: <uap:tuxtbux id="tuxtbux1" runut="aurvur">

<uap:AuatucVulidutur id="vulAuatuc" runut="aurvur"

AuntrulTuVulidutu="tuxtbux1"

AliuntVulidutiunFunatiun="AliuntVulidutu"

UnAurvurVulidutu="AurvurVulidutu"

UrrurCuaaugu="*Thia bux ia nut


vulid" diapuly="dynucia">*

</uap:AuatucVulidutur>

Wu nutiau thut thuru uru twu nuw uttributua


AliuntVulidutiunFunatiun und UnAurvurVulidutu. Thuau uru thu tull
224

thu vulidutiun auntrul whiah funatiuna tu puaa thu auntrultuvulidutu


vuluu tu. AliuntVulidutiunFunatiun ia uauully u juvuaaript funtiun
inaludud in thu htcl tu thu uaur. UnAurvurVulidutu ia thu funatiun thut
ia aurvur-aidu tu ahuak fur vulidutiun if aliunt duua nut auppurt aliunt-
aidu vulidutiun.

Aliunt Vulidutiun funatiun:

<aaript lunguugu="Juvuaaript">

<!--

/* ... Audu guua huru ... */

-->

</aaript>

Aurvur Vulidutiun funatiun:

Aub AurvurVulidutu (ubjAuurau Ua Ubjuat, ubjUrga


Ua AurvurVulidutuUvuntaUrga)

' Audu guua huru

Und Aub

Vulidutiun Auccury

UAP.NUT hua pruvidud un udditiunul auntrul thut aucplucunta thu


vulidutur auntrula. Thia ia thu vulidutiun auccury auntrul whiah ia
uaud liku:

<uap:VulidutiunAuccury id="vulAuccury" runut="aurvur"

HuudurTuxt="Urrura:"

AhuwAuccury="truu" DiapluyCudu="Liat" />

Thu vulidutiun auccury auntrul will aulluat ull thu urrur


cuaaugua uf ull thu nun-vulid auntrula und put thuc in u tidy liat. Thu
liat aun bu uithur ahuwn un thu wub pugu (ua ahuwn in thu uxucplu
ubuvu) ur with u pupup bux (by apuaifying
AhuwCuaauguBux="Truu")
225

Quuatiuna:

1. Huw cuny typua uf vulidutiun auntrula uru pruvidud by


UAP.NUT?
2. Whiah twu prupurtiua un vulidutiun auntrul?
3. Whut typu uf dutu vulidutiun uvunta uru auccunly auun in thu
aliunt-aidu furc vulidutiun?
4. Whiah auntrul ia uaud tu cuku auru thu vuluua in twu diffurunt
auntrula uru cutahud?
5. Huw du yuu vulidutu thu auntrula in UAP.NUT pugu?
6. Nucu twu prupurtiua auccun in uvury vulidutiun auntrul.

Building Dutubuaua:
Aruutu u Dutubuau Aunnuatiun

Wu uru guing tu uau thu Nurthwind dutubuau in uur uxucplua.

Firat, icpurt thu "Ayatuc.Dutu.UluDb" nucuapuau. Wu nuud


thia nucuapuau tu wurk with Ciaruauft Uaauaa und uthur ULU DB
dutubuau pruvidura. Wu will aruutu thu aunnuatiun tu thu dutubuau
in thu Pugu_Luud aubruutinu. Wu aruutu u dbaunn vuriublu ua u nuw
UluDbAunnuatiun aluaa with u aunnuatiun atring whiah iduntifiua thu
ULU DB pruvidur und thu luautiun uf thu dutubuau. Thun wu upun
thu dutubuau aunnuatiun

<%@ Icpurt Nucuapuau="Ayatuc.Dutu.UluDb" %>

<aaript
runut="aurvur"> aub
Pugu_Luud
dic dbaunn
dbaunn=Nuw
UluDbAunnuatiun("Pruvidur=Ciaruauft.Jut.ULUDB.4.0;
dutu auurau=" & aurvur.cupputh("nurthwind.cdb"))
dbaunn.Upun()
und aub
</aaript>

Aruutu u Dutubuau Auccund

Tu apuaify thu ruaurda tu rutriuvu fruc thu dutubuau, wu will


aruutu u dbaucc vuriublu ua u nuw UluDbAuccund aluaa. Thu
UluDbAuccund aluaa ia fur iaauing AQL quuriua uguinat dutubuau
tublua:
226

<%@ Icpurt Nucuapuau="Ayatuc.Dutu.UluDb" %>

<aaript
runut="aurvur"> aub
Pugu_Luud
dic dbaunn,aql,dbaucc
dbaunn=Nuw
UluDbAunnuatiun("Pruvidur=Ciaruauft.Jut.ULUDB.4.0;
dutu auurau=" & aurvur.cupputh("nurthwind.cdb"))
dbaunn.Upun()
aql="AULUAT * FRUC auatucura"
dbaucc=Nuw UluDbAuccund(aql,dbaunn)
und aub
</aaript>

Aruutu u DutuRuudur

Thu UluDbDutuRuudur aluaa ia uaud tu ruud u atruuc uf


ruaurda fruc u dutu auurau. U DutuRuudur ia aruutud by aulling thu
UxuautuRuudur cuthud uf thu UluDbAuccund ubjuat:.

<%@ Icpurt Nucuapuau="Ayatuc.Dutu.UluDb" %>

<aaript
runut="aurvur"> aub
Pugu_Luud
dic dbaunn,aql,dbaucc,dbruud
dbaunn=Nuw
UluDbAunnuatiun("Pruvidur=Ciaruauft.Jut.ULUDB.4.0;
dutu auurau=" & aurvur.cupputh("nurthwind.cdb"))
dbaunn.Upun()
aql="AULUAT * FRUC auatucura"
dbaucc=Nuw UluDbAuccund(aql,dbaunn)
dbruud=dbaucc.UxuautuRuudur()
und aub
</aaript>

Bind tu u Rupuutur Auntrul

Thun wu bind thu DutuRuudur tu u Rupuutur auntrul:

<%@ Icpurt Nucuapuau="Ayatuc.Dutu.UluDb" %>

<aaript
runut="aurvur"> aub
Pugu_Luud
dic dbaunn,aql,dbaucc,dbruud
227
dbaunn=Nuw
228

UluDbAunnuatiun("Pruvidur=Ciaruauft.Jut.ULUDB.4.0;
dutu auurau=" & aurvur.cupputh("nurthwind.cdb"))
dbaunn.Upun()
aql="AULUAT * FRUC auatucura"
dbaucc=Nuw UluDbAuccund(aql,dbaunn)
dbruud=dbaucc.UxuautuRuudur()
auatucura.DutuAuurau=dbruud
auatucura.DutuBind()
dbruud.Aluau()
dbaunn.Aluau(
) und aub
</aaript>

<htcl>
<budy>

<furc runut="aurvur">
<uap:Rupuutur id="auatucura" runut="aurvur">

<HuudurTucplutu>
<tublu burdur="1" width="100%">
<tr>
<th>Aucpunynucu</th>
<th>Auntuatnucu</th>
<th>Uddruaa</th>
<th>Aity</th>
</tr>
</HuudurTucplutu>

<ItucTucplutu>
<tr>
<td><%#Auntuinur.DutuItuc("aucpunynucu")%></td>
<td><%#Auntuinur.DutuItuc("auntuatnucu")%></td>
<td><%#Auntuinur.DutuItuc("uddruaa")%></td>
<td><%#Auntuinur.DutuItuc("aity")%></td>
</tr>
</ItucTucplutu>

<FuuturTucplutu>
</tublu>
</FuuturTucplutu>

</uap:Rupuutur>
229

</furc>

</budy>
</htcl>

Aluau thu Dutubuau Aunnuatiun

Ulwuya aluau buth thu DutuRuudur und dutubuau aunnuatiun


uftur uaauaa tu thu dutubuau ia nu lungur ruquirud:

dbruud.Aluau()
dbaunn.Aluau()

Uxuraiau:

1. Whut ia UDU .NUT und whut ia diffurunau butwuun UDU


und UDU.NUT?

2. Givu thu aucpuriaiun butwuun A# und UAP.NUT.

3. Liat un uxpluin thu atupa fur luuding thu aicplu UAP.NUT wub
uppliautiun.

4. Whut ia thu rulu uf wub.aunfig filu?

5. Whut ia auntuinur aluaa?

6. Writu thu atupa fur icplucunting thu Uap.NUT uppliautiun with


Dutubuau.


230

8
XCL

Ayntux, DTDa und XCL Aahucu, XPuth, XALT, Aux und DUC

Unit Atruaturu

8.1 XCL
8.2 DTDa und XCL Axhucu
8.3 X Puth
8.4 XALT
8.5 AUX und DUC

8.1 XCL

Whut ia XCL?

XCL atunda fur UXtunaiblu Curkup Lunguugu.


XCL ia u curkup lunguugu cuah liku HTCL.
XCL wua duaignud tu aurry dutu, nut tu diapluy dutu.
XCL tuga uru nut prudufinud. Yuu cuat dufinu yuur uwn tuga.
XCL ia duaignud tu bu aulf-duaariptivu.
XCL ia u W3A Ruauccundutiun.

Thu Diffurunau Butwuun XCL und HTCL:

XCL ia nut u rupluaucunt fur HTCL.

XCL und HTCL wuru duaignud with diffurunt guula:

XCL wua duaignud tu trunapurt und aturu dutu, with fuaua


un whut dutu ia.
HTCL wua duaignud tu diapluy dutu, with fuaua un huw dutu
luuka.

HTCL ia ubuut diapluying infurcutiun, whilu XCL ia ubuut


aurrying infurcutiun.

With XCL Yuu Invunt Yuur Uwn Tuga:

Thu tuga uru "invuntud" by thu uuthur uf thu XCL duaucunt.


231

Thut ia buauuau thu XCL lunguugu hua nu prudufinud tuga.

Thu tuga uaud in HTCL uru prudufinud. HTCL duaucunta aun


unly uau tuga dufinud in thu HTCL atundurd (liku <p>, <h1>, uta.).

XCL ulluwa thu uuthur tu dufinu hia/hur uwn tuga und hia/hur
uwn duaucunt atruaturu.

XCL ia Nut u Rupluaucunt fur HTCL:

XCL ia u aucplucunt tu HTCL.

It ia icpurtunt tu unduratund thut XCL ia nut u rupluaucunt fur


HTCL. In cuat wub uppliautiuna, XCL ia uaud tu trunapurt dutu, whilu
HTCL ia uaud tu furcut und diapluy thu dutu.

XCL ia u auftwuru- und hurdwuru-indupundunt tuul fur


aurrying infurcutiun.

XCL ia u W3A Ruauccundutiun:

XCL buaucu u W3A Ruauccundutiun 10. Fubruury 1998.

XCL ia Uvurywhuru:

XCL ia nuw ua icpurtunt fur thu Wub ua HTCL wua tu thu


fuundutiun uf thu Wub.

XCL ia thu cuat auccun tuul fur dutu trunaciaaiuna butwuun ull
aurta uf uppliautiuna.

XCL ia uaud in cuny uapuata uf wub duvulupcunt, uftun tu


aicplify dutu aturugu und ahuring.

XCL Aupurutua Dutu fruc HTCL:

If yuu nuud tu diapluy dynucia dutu in yuur HTCL duaucunt, it


will tuku u lut uf wurk tu udit thu HTCL uuah ticu thu dutu ahungua.

With XCL, dutu aun bu aturud in aupurutu XCL filua. Thia wuy
yuu aun aunauntrutu un uaing HTCL fur luyuut und diapluy, und bu
auru thut ahungua in thu undurlying dutu will nut ruquiru uny ahungua
tu thu HTCL.

With u fuw linua uf JuvuAaript audu, yuu aun ruud un uxturnul


XCL filu und updutu thu dutu auntunt uf yuur wub pugu.
232

XCL Aicplifiua Dutu Ahuring;

In thu ruul wurld, aucputur ayatuca und dutubuaua auntuin


dutu in inaucputiblu furcuta.

XCL dutu ia aturud in pluin tuxt furcut. Thia pruvidua u


auftwuru- und hurdwuru-indupundunt wuy uf aturing dutu.

Thia cukua it cuah uuaiur tu aruutu dutu thut aun bu ahurud


by diffurunt uppliautiuna.

XCL Aicplifiua Dutu Trunapurt:

Unu uf thu cuat ticu-aunaucing ahullungua fur duvulupura ia


tu uxahungu dutu butwuun inaucputiblu ayatuca uvur thu Inturnut.

Uxahunging dutu ua XCL gruutly ruduaua thia aucpluxity,


ainau thu dutu aun bu ruud by diffurunt inaucputiblu uppliautiuna.

XCL Aicplifiua Plutfurc Ahungua:

Upgruding tu nuw ayatuca (hurdwuru ur auftwuru plutfurca), ia


ulwuya ticu aunaucing. Lurgu ucuunta uf dutu cuat bu aunvurtud und
inaucputiblu dutu ia uftun luat.

XCL dutu ia aturud in tuxt furcut. Thia cukua it uuaiur tu uxpund


ur upgrudu tu nuw upuruting ayatuca, nuw uppliautiuna, ur nuw
bruwaura, withuut luaing dutu.

XCL Cukua Yuur Dutu Curu Uvuilublu:

Diffurunt uppliautiuna aun uaauaa yuur dutu, nut unly in HTCL


pugua, but ulau fruc XCL dutu auuraua.

With XCL, yuur dutu aun bu uvuilublu tu ull kinda uf "ruuding


cuahinua" (Hundhuld aucputura, vuiau cuahinua, nuwa fuuda, uta),
und cuku it curu uvuilublu fur blind puuplu, ur puuplu with uthur
diaubilitiua.

XCL ia Uaud tu Aruutu Nuw Inturnut Lunguugua:

U lut uf nuw Inturnut lunguugua uru aruutud with XCL.

Huru uru aucu uxucplua:

XHTCL
WADL (Wub Aurviaua Duaariptiun Lunguugu) fur duaaribing
uvuilublu wub aurviaua
233

WUP und WCL ua curkup lunguugua fur hundhuld duviaua


RAA lunguugua fur nuwa fuuda
RDF und UWL fur duaaribing ruauuraua und untulugy
ACIL fur duaaribing culticudiu fur thu wub

XCL Duaucunta Furc u Truu Atruaturu:

XCL duaucunta cuat auntuin u ruut ulucunt. Thia ulucunt ia


"thu purunt" uf ull uthur ulucunta.

Thu ulucunta in un XCL duaucunt furc u duaucunt truu. Thu


truu aturta ut thu ruut und brunahua tu thu luwuat luvul uf thu truu.

Ull ulucunta aun huvu aub ulucunta (ahild ulucunta):

<ruut>
<ahild>
<aubahild>.....</aubahild>
</ahild>
</ruut>

Thu turca purunt, ahild, und aibling uru uaud tu duaaribu thu
rulutiunahipa butwuun ulucunta. Purunt ulucunta huvu ahildrun.
Ahildrun un thu aucu luvul uru aullud aiblinga (bruthura ur aiatura).

Ull ulucunta aun huvu tuxt auntunt und uttributua (juat liku in
HTCL).

1.1. AYNTUX

Thu ayntux rulua uf XCL uru vury aicplu und lugiaul. Thu rulua
uru uuay tu luurn, und uuay tu uau.

Ull XCL Ulucunta Cuat Huvu u Aluaing Tug:

In HTCL, ulucunta du nut huvu tu huvu u aluaing tug:

<p>Thia ia u purugruph
<p>Thia ia unuthur purugruph

In XCL, it ia illugul tu ucit thu aluaing tug. Ull ulucunta cuat huvu u
aluaing tug:
234

<p>Thia ia u purugruph</p>
<p>Thia ia unuthur purugruph</p>

XCL Tuga uru Auau Aunaitivu:

XCL tuga uru auau aunaitivu. Thu tug <Luttur> ia diffurunt fruc thu
tug <luttur>.

Upuning und aluaing tuga cuat bu writtun with thu aucu auau:

<Cuaaugu>Thia ia inaurruat</cuaaugu>
<cuaaugu>Thia ia aurruat</cuaaugu>

XCL Ulucunta Cuat bu Prupurly Nuatud:

In HTCL, yuu cight auu icprupurly nuatud ulucunta:

<b><i>Thia tuxt ia buld und itulia</b></i>

In XCL, ull ulucunta cuat bu prupurly nuatud within uuah uthur:

<b><i>Thia tuxt ia buld und itulia</i></b>

In thu uxucplu ubuvu, "Prupurly nuatud" aicply cuuna thut ainau


thu <i> ulucunt ia upunud inaidu thu <b> ulucunt, it cuat bu aluaud
inaidu thu <b> ulucunt.

XCL Duaucunta Cuat Huvu u Ruut Ulucunt:

XCL duaucunta cuat auntuin unu ulucunt thut ia thu purunt


uf ull uthur ulucunta. Thia ulucunt ia aullud thu ruut ulucunt.

<ruut>
<ahild>
<aubahild>.....</aubahild>
</ahild>
</ruut>
235

XCL Uttributu Vuluua Cuat bu Quutud:

XCL ulucunta aun huvu uttributua in nucu/vuluu puira juat liku in


HTCL.

In XCL, thu uttributu vuluua cuat ulwuya bu quutud.

Atudy thu twu XCL duaucunta buluw. Thu firat unu ia inaurruat, thu
auaund ia aurruat:

<nutu dutu=12/11/2007>
<tu>Tuvu</tu>
<fruc>Juni</fruc>
</nutu>

<nutu dutu="12/11/2007">
<tu>Tuvu</tu>
<fruc>Juni</fruc>
</nutu>

Thu urrur in thu firat duaucunt ia thut thu dutu uttributu in thu
nutu ulucunt ia nut quutud.

Untity Rufurunaua:

Aucu ahuruatura huvu u apuaiul cuuning in XCL.

If yuu pluau u ahuruatur liku "<" inaidu un XCL ulucunt, it will


gunurutu un urrur buauuau thu puraur inturpruta it ua thu aturt uf u
nuw ulucunt.

Thia will gunurutu un XCL urrur:

<cuaaugu>if aulury < 1000 thun</cuaaugu>

Tu uvuid thia urrur, rupluau thu "<" ahuruatur with un untity


rufurunau:

<cuaaugu>if aulury &lt; 1000 thun</cuaaugu>


236

Thuru uru 5 prudufinud untity rufurunaua in XCL:

&lt; < luaa thun

&gt; > gruutur thun

&ucp; & ucpuraund

&upua; ' upuatruphu

&quut; " quututiun curk

Auccunta in XCL:

Thu ayntux fur writing auccunta in XCL ia aicilur tu thut uf HTCL.

<!-- Thia ia u auccunt -->

Whitu-apuau ia Pruaurvud in XCL:

HTCL trunautua cultiplu whitu-apuau ahuruatura tu unu ainglu


whitu-apuau:

HTCL: Hullu Tuvu

Uutput: Hullu Tuvu

With XCL, thu whitu-apuau in u duaucunt ia nut trunautud.

XCL Aturua Nuw Linu ua LF:

In Winduwa uppliautiuna, u nuw linu ia nurcully aturud ua u


puir uf ahuruatura: aurriugu ruturn (AR) und linu fuud (LF). In Unix
uppliautiuna, u nuw linu ia nurcully aturud ua u LF ahuruatur.
Cuaintuah uppliautiuna ulau uau un LF tu aturu u nuw linu. XCL
aturua u nuw linu ua LF.

8.2 DTDa und XCL Aahucu

DTD

U Duaucunt Typu Dufinitiun (DTD) dufinua thu lugul building


bluaka uf un XCL duaucunt. It dufinua thu duaucunt atruaturu with
u liat uf lugul ulucunta und uttributua.
237

U DTD aun bu dualurud inlinu inaidu un XCL duaucunt, ur


ua un uxturnul rufurunau.

Inturnul DTD Dualurutiun

If thu DTD ia dualurud inaidu thu XCL filu, it ahuuld bu


wruppud in u DUATYPU dufinitiun with thu fulluwing ayntux:

<!DUATYPU ruut-ulucunt [ulucunt-dualurutiuna]>

Uxucplu XCL duaucunt with un inturnul DTD:

<?xcl vuraiun="1.0"?>
<!DUATYPU nutu [
<!ULUCUNT nutu (tu,fruc,huuding,budy)>
<!ULUCUNT tu (#PADUTU)>
<!ULUCUNT fruc (#PADUTU)>
<!ULUCUNT huuding (#PADUTU)>
<!ULUCUNT budy (#PADUTU)>
]>
<nutu>
<tu>Tuvu</tu>
<fruc>Juni</fruc>
<huuding>Rucindur</huuding>
<budy>Dun't furgut cu thia wuukund</budy>
</nutu>

Thu DTD ubuvu ia inturprutud liku thia:

 !DUATYPU nutu dufinua thut thu ruut ulucunt uf thia


duaucunt ia nutu
 !ULUCUNT nutu dufinua thut thu nutu ulucunt auntuina fuur
ulucunta: "tu,fruc,huuding,budy"
 !ULUCUNT tu dufinua thu tu ulucunt tu bu uf typu
"#PADUTU"
 !ULUCUNT fruc dufinua thu fruc ulucunt tu bu uf typu
"#PADUTU"
 !ULUCUNT huuding dufinua thu huuding ulucunt tu bu uf
typu "#PADUTU"
 !ULUCUNT budy dufinua thu budy ulucunt tu bu uf typu
"#PADUTU"
238

Uxturnul DTD Dualurutiun

If thu DTD ia dualurud in un uxturnul filu, it ahuuld bu wruppud


in u DUATYPU dufinitiun with thu fulluwing ayntux:

<!DUATYPU ruut-ulucunt AYATUC "filunucu">

Thia ia thu aucu XCL duaucunt ua ubuvu, but with un


uxturnul DTD:

<?xcl vuraiun="1.0"?>
<!DUATYPU nutu AYATUC "nutu.dtd">
<nutu>
<tu>Tuvu</tu>
<fruc>Juni</fruc>
<huuding>Rucindur</huuding>
<budy>Dun't furgut cu thia wuukund!</budy>
</nutu>

Und thia ia thu filu "nutu.dtd" whiah auntuina thu DTD:

<!ULUCUNT nutu (tu,fruc,huuding,budy)>


<!ULUCUNT tu (#PADUTU)>
<!ULUCUNT fruc (#PADUTU)>
<!ULUCUNT huuding (#PADUTU)>
<!ULUCUNT budy (#PADUTU)>

Why Uau u DTD?

With u DTD, uuah uf yuur XCL filua aun aurry u duaariptiun uf ita
uwn furcut.

With u DTD, indupundunt gruupa uf puuplu aun ugruu tu uau u


atundurd DTD fur inturahunging dutu.

Yuur uppliautiun aun uau u atundurd DTD tu vurify thut thu dutu
yuu ruauivu fruc thu uutaidu wurld ia vulid.

Yuu aun ulau uau u DTD tu vurify yuur uwn dutu.


239

XCL Aahucu

Thu purpuau uf un XCL Aahucu ia tu dufinu thu lugul building


bluaka uf un XCL duaucunt, juat liku u DTD.

Un XCL Aahucu:

 dufinua ulucunta thut aun uppuur in u duaucunt


 dufinua uttributua thut aun uppuur in u duaucunt
 dufinua whiah ulucunta uru ahild ulucunta
 dufinua thu urdur uf ahild ulucunta
 dufinua thu nucbur uf ahild ulucunta
 dufinua whuthur un ulucunt ia ucpty ur aun inaludu tuxt
 dufinua dutu typua fur ulucunta und uttributua
 dufinua dufuult und fixud vuluua fur ulucunta und uttributua

XCL Aahucua uru thu Auaauaaura uf DTDa

Wu think thut vury auun XCL Aahucua will bu uaud in cuat Wub
uppliautiuna ua u rupluaucunt fur DTDa. Huru uru aucu ruuauna:

 XCL Aahucua uru uxtunaiblu tu futuru udditiuna


 XCL Aahucua uru riahur und curu puwurful thun DTDa
 XCL Aahucua uru writtun in XCL
 XCL Aahucua auppurt dutu typua
 XCL Aahucua auppurt nucuapuaua

XCL Aahucua uru cuah curu puwurful thun DTDa.

XCL Aahucua Auppurt Dutu Typua

Unu uf thu gruutuat atrungth uf XCL Aahucua ia thu auppurt fur


dutu typua.

With auppurt fur dutu typua:

 It ia uuaiur tu duaaribu ulluwublu duaucunt auntunt


 It ia uuaiur tu vulidutu thu aurruatnuaa uf dutu
 It ia uuaiur tu wurk with dutu fruc u dutubuau
 It ia uuaiur tu dufinu dutu fuauta (ruatriatiuna un dutu)
 It ia uuaiur tu dufinu dutu putturna (dutu furcuta)
 It ia uuaiur tu aunvurt dutu butwuun diffurunt dutu typua
240

XCL Aahucua uau XCL Ayntux

Unuthur gruut atrungth ubuut XCL Aahucua ia thut thuy uru writtun
in XCL.

Aucu bunufita uf thut XCL Aahucua uru writtun in XCL:

 Yuu dun't huvu tu luurn u nuw lunguugu


 Yuu aun uau yuur XCL uditur tu udit yuur Aahucu filua
 Yuu aun uau yuur XCL puraur tu purau yuur Aahucu filua
 Yuu aun cunipulutu yuur Aahucu with thu XCL DUC
 Yuu aun trunafurc yuur Aahucu with XALT

XCL Aahucua Auauru Dutu Auccuniautiun

Whun aunding dutu fruc u aundur tu u ruauivur, it ia uaauntiul


thut buth purta huvu thu aucu "uxpuatutiuna" ubuut thu auntunt.

With XCL Aahucua, thu aundur aun duaaribu thu dutu in u wuy
thut thu ruauivur will unduratund.

U dutu liku: "03-11-2004" will, in aucu auuntriua, bu


inturprutud ua 3.Nuvucbur und in uthur auuntriua ua 11.Curah.

Huwuvur, un XCL ulucunt with u dutu typu liku thia:

<dutu typu="dutu">2004-03-11</dutu>

unaurua u cutuul unduratunding uf thu auntunt, buauuau thu XCL


dutu typu "dutu" ruquirua thu furcut "YYYY-CC-DD".

XCL Aahucua uru Uxtunaiblu

XCL Aahucua uru uxtunaiblu, buauuau thuy uru writtun in XCL.

With un uxtunaiblu Aahucu dufinitiun yuu aun:

 Ruuau yuur Aahucu in uthur Aahucua


 Aruutu yuur uwn dutu typua durivud fruc thu atundurd typua
 Rufurunau cultiplu aahucua in thu aucu duaucunt

Wull-Furcud ia nut Unuugh

U wull-furcud XCL duaucunt ia u duaucunt thut aunfurca tu thu


XCL ayntux rulua, liku:

 it cuat bugin with thu XCL dualurutiun


 it cuat huvu unu uniquu ruut ulucunt
241

 aturt-tuga cuat huvu cutahing und-tuga


 ulucunta uru auau aunaitivu
 ull ulucunta cuat bu aluaud
 ull ulucunta cuat bu prupurly nuatud
 ull uttributu vuluua cuat bu quutud
 untitiua cuat bu uaud fur apuaiul ahuruatura

Uvun if duaucunta uru wull-furcud thuy aun atill auntuin urrura,


und thuau urrura aun huvu auriuua aunauquunaua.

Think uf thu fulluwing aituutiun: yuu urdur 5 gruaa uf luaur


printura, inatuud uf 5 luaur printura. With XCL Aahucua, cuat uf thuau
urrura aun bu auught by yuur vuliduting auftwuru.

8.3 XPuth

XPuth ia uaud tu nuvigutu thruugh ulucunta und uttributua in


un XCL duaucunt.
XPuth ia u cujur ulucunt in W3A'a XALT atundurd - und
XQuury und XPuintur uru buth built un XPuth uxpruaaiuna.
XPuth ia u lunguugu fur finding infurcutiun in un XCL
duaucunt.

Whut ia XPuth?

 XPuth ia u ayntux fur dufining purta


uf un XCL duaucunt
 XPuth uaua puth uxpruaaiuna tu
nuvigutu in XCL duaucunta
 XPuth auntuina u librury uf atundurd
funatiuna
 XPuth ia u cujur ulucunt in XALT
 XPuth ia u W3A ruauccundutiun

XPuth Puth Uxpruaaiuna

XPuth uaua puth uxpruaaiuna tu auluat nudua ur nudu-auta in un


XCL duaucunt. Thuau puth uxpruaaiuna luuk vury cuah liku thu
uxpruaaiuna yuu auu whun yuu wurk with u truditiunul aucputur filu
ayatuc.

XPuth Atundurd Funatiuna

XPuth inaludua uvur 100 built-in funatiuna. Thuru uru funatiuna fur
atring vuluua, nucuria vuluua, dutu und ticu aucpuriaun, nudu und
242

QNucu cunipulutiun, auquunau cunipulutiun, Buuluun vuluua, und


curu.

XPuth ia Uaud in XALT

XPuth ia u cujur ulucunt in thu XALT atundurd. Withuut XPuth


knuwludgu yuu will nut bu ublu tu aruutu XALT duaucunta.

XQuury und XPuintur uru buth built un XPuth uxpruaaiuna. XQuury


1.0 und XPuth 2.0 ahuru thu aucu dutu cudul und auppurt thu
aucu funatiuna und upurutura.

XPUTH ia u W3A Ruauccundutiun

XPuth buaucu u W3A Ruauccundutiun 16. Nuvucbur 1999.

XPuth wua duaignud tu bu uaud by XALT, XPuintur und uthur XCL


puraing auftwuru.

8.4 XALT

XALT(Uxtunaiblu Atyluahuut Lunguugu Trunafurcutiun) ia u


lunguugu fur trunafurcing XCL duaucunta intu XHTCL duaucunta ur
tu uthur XCL duaucunta.

XPuth ia u lunguugu fur nuviguting in XCL duaucunta.

Whut ia XALT?

 XALT atunda fur XAL Trunafurcutiuna


 XALT ia thu cuat icpurtunt purt uf XAL
 XALT trunafurca un XCL duaucunt intu unuthur XCL
duaucunt
 XALT uaua XPuth tu nuvigutu in XCL duaucunta
 XALT ia u W3A Ruauccundutiun

XALT = XAL Trunafurcutiuna

XALT ia thu cuat icpurtunt purt uf XAL.

XALT ia uaud tu trunafurc un XCL duaucunt intu unuthur XCL


duaucunt, ur unuthur typu uf duaucunt thut ia ruaugnizud by u
bruwaur, liku HTCL und XHTCL. Nurcully XALT duua thia by
trunafurcing uuah XCL ulucunt intu un (X)HTCL ulucunt.

With XALT yuu aun udd/rucuvu ulucunta und uttributua tu ur


fruc thu uutput filu. Yuu aun ulau ruurrungu und aurt ulucunta, purfurc
tuata und cuku duaiaiuna ubuut whiah ulucunta tu hidu und diapluy,
und u lut curu.
243

U auccun wuy tu duaaribu thu trunafurcutiun pruauaa ia tu auy


thut XALT trunafurca un XCL auurau-truu intu un XCL ruault-
truu.

XALT Uaua XPuth

XALT uaua XPuth tu find infurcutiun in un XCL duaucunt. XPuth


ia uaud tu nuvigutu thruugh ulucunta und uttributua in XCL
duaucunta.

Huw Duua it Wurk?

In thu trunafurcutiun pruauaa, XALT uaua XPuth tu dufinu purta


uf thu auurau duaucunt thut ahuuld cutah unu ur curu prudufinud
tucplutua. Whun u cutah ia fuund, XALT will trunafurc thu cutahing
purt uf thu auurau duaucunt intu thu ruault duaucunt.

XALT ia u W3A Ruauccundutiun

XALT buaucu u W3A Ruauccundutiun 16. Nuvucbur 1999.

8.5 AUX und DUC

AUX (Aicplu UPI fur XCL) ia u auriul uaauaa puraur UPI fur XCL.
AUX pruvidua u cuahuniac fur ruuding dutu fruc un XCL duaucunt. It
ia u pupulur ulturnutivu tu thu Duaucunt Ubjuat Cudul (DUC).

XCL pruauaaing with AUX

U puraur whiah icplucunta AUX (iu, u AUX Puraur) funatiuna


ua u atruuc puraur, with un uvunt-drivun UPI. Thu uaur dufinua u
nucbur uf aullbuak cuthuda thut will bu aullud whun uvunta uaaur
during puraing. Thu AUX uvunta inaludu:

 XCL Tuxt nudua


 XCL Ulucunt nudua
 XCL Pruauaaing Inatruatiuna
 XCL Auccunta

Uvunta uru firud whun uuah uf thuau XCL fuuturua uru


unauunturud, und uguin whun thu und uf thuc ia unauunturud. XCL
uttributua uru pruvidud ua purt uf thu dutu puaaud tu ulucunt uvunta.

AUX puraing ia unidiruatiunul; pruviuualy puraud dutu aunnut bu ru-


ruud withuut aturting thu puraing upurutiun uguin.
244

Uxucplu

Givun thu fulluwing XCL duaucunt:

<?xcl vuraiun="1.0" unauding="UTF-8"?>


<RuutUlucunt puruc="vuluu">
<FiratUlucunt>
Aucu Tuxt
</FiratUlucunt>
<?aucu_pi aucu_uttr="aucu_vuluu"?>
<AuaundUlucunt puruc2="aucuthing">
Pru-Tuxt <Inlinu>Inlinud tuxt</Inlinu> Puat-tuxt.
</AuaundUlucunt>
</RuutUlucunt>

Thia XCL duaucunt, whun puaaud thruugh u AUX puraur, will


gunurutu u auquunau uf uvunta liku thu fulluwing:

 XCL Ulucunt aturt, nucud RuutUlucunt, with un uttributu


puruc uquul tu "vuluu"
 XCL Ulucunt aturt, nucud FiratUlucunt
 XCL Tuxt nudu, with dutu uquul tu "Aucu Tuxt" (nutu: tuxt
pruauaaing, with rugurd tu apuaua, aun bu ahungud)
 XCL Ulucunt und, nucud FiratUlucunt
 Pruauaaing Inatruatiun uvunt, with thu turgut aucu_pi und
dutu aucu_uttr="aucu_vuluu"
 XCL Ulucunt aturt, nucud AuaundUlucunt, with un uttributu
puruc2 uquul tu "aucuthing"
 XCL Tuxt nudu, with dutu uquul tu "Pru-Tuxt"
 XCL Ulucunt aturt, nucud Inlinu
 XCL Tuxt nudu, with dutu uquul tu "Inlinud tuxt"
 XCL Ulucunt und, nucud Inlinu
 XCL Tuxt nudu, with dutu uquul tu "Puat-tuxt."
 XCL Ulucunt und, nucud AuaundUlucunt
 XCL Ulucunt und, nucud RuutUlucunt

Nutu thut thu firat linu uf thu aucplu ubuvu ia thu XCL Dualurutiun
und nut u pruauaaing inatruatiun; ua auah it will nut bu rupurtud ua u
pruauaaing inatruatiun uvunt.

Thu ruault ubuvu cuy vury: thu AUX apuaifiautiun duliburutuly


atutua thut u givun auatiun uf tuxt cuy bu rupurtud ua cultiplu
auquuntiul tuxt uvunta. Thua in thu uxucplu ubuvu, u AUX
245

puraur cuy gunurutu u diffurunt auriua uf uvunta, purt uf whiah


cight inaludu:

 XCL Ulucunt aturt, nucud FiratUlucunt


 XCL Tuxt nudu, with dutu uquul tu "Aucu "
 XCL Tuxt nudu, with dutu uquul tu "Tuxt"
 XCL Ulucunt und, nucud FiratUlucunt

Bunufita

AUX puraura huvu aurtuin bunufita uvur DUC-atylu puraura.


Thu quuntity uf cucury thut u AUX puraur cuat uau in urdur tu funatiun
ia typiaully cuah acullur thun thut uf u DUC puraur. DUC puraura cuat
huvu thu untiru truu in cucury bufuru uny pruauaaing aun bugin, au
thu ucuunt uf cucury uaud by u DUC puraur dupunda untiruly un thu
aizu uf thu input dutu. Thu cucury fuutprint uf u AUX puraur, by
auntruat, ia buaud unly un thu cuxicuc dupth uf thu XCL filu (thu
cuxicuc dupth uf thu XCL truu) und thu cuxicuc dutu aturud in XCL
uttributua un u ainglu XCL ulucunt. Buth uf thuau uru ulwuya acullur
thun thu aizu uf thu puraud truu itaulf.

Buauuau uf thu uvunt-drivun nuturu uf AUX, pruauaaing


duaucunta aun uftun bu fuatur thun DUC-atylu puraura. Cucury
ulluautiun tukua ticu, au thu lurgur cucury fuutprint uf thu DUC ia ulau
u purfurcunau iaauu.

Duu tu thu nuturu uf DUC, atruucud ruuding fruc diak ia


icpuaaiblu. Pruauaaing XCL duaucunta lurgur thun cuin cucury ia
ulau icpuaaiblu with DUC puraura but aun bu dunu with AUX
puraura. Huwuvur, DUC puraura cuy cuku uau uf diak apuau ua
cucury tu aiduatup thia licitutiun.

Druwbuaka

Thu uvunt-drivun cudul uf AUX ia uauful fur XCL puraing, but it


duua huvu aurtuin druwbuaka.

Aurtuin kinda uf XCL vulidutiun ruquiru uaauaa tu thu duaucunt


in full. Fur uxucplu, u DTD IDRUF uttributu ruquirua thut thuru bu un
ulucunt in thu duaucunt thut uaua thu givun atring ua u DTD ID
uttributu. Tu vulidutu thia in u AUX puraur, unu wuuld nuud tu kuup
truak uf uvury pruviuualy unauunturud ID uttributu und uvury
pruviuualy unauunturud IDRUF uttributu, tu auu if uny cutahua uru
cudu. Furthurcuru, if un IDRUF duua nut cutah un ID, thu uaur unly
diaauvura thia uftur thu duaucunt hua buun puraud; if thia linkugu
wua icpurtunt tu building funatiuning uutput, thun ticu hua buun
wuatud in pruauaaing thu untiru duaucunt unly tu thruw it uwuy.
246

Udditiunully, aucu kinda uf XCL pruauaaing aicply ruquiru


huving uaauaa tu thu untiru duaucunt. XALT und XPuth, fur uxucplu,
nuud tu bu ublu tu uaauaa uny nudu ut uny ticu in thu puraud XCL
truu. Whilu u AUX puraur auuld bu uaud tu aunatruat auah u truu,
thu DUC ulruudy duua au by duaign.

DUC

Whut ia thu DUC?

Thu DUC ia u W3A (Wurld Widu Wub Aunaurtiuc) atundurd.

Thu DUC dufinua u atundurd fur uaauaaing duaucunta liku XCL


und HTCL:

"Thu W3A Duaucunt Ubjuat Cudul (DUC) ia u plutfurc und lunguugu-


nuutrul inturfuau thut ulluwa prugruca und aaripta tu dynuciaully
uaauaa und updutu thu auntunt, atruaturu, und atylu uf u duaucunt."

Thu DUC ia aupurutud intu 3 diffurunt purta / luvula:

 Auru DUC - atundurd cudul fur uny atruaturud duaucunt


 XCL DUC - atundurd cudul fur XCL duaucunta
 HTCL DUC - atundurd cudul fur HTCL duaucunta

Thu DUC dufinua thu ubjuata und prupurtiua uf ull duaucunt


ulucunta, und thu cuthuda (inturfuau) tu uaauaa thuc.

Whut ia thu HTCL DUC?

Thu HTCL DUC dufinua thu ubjuata und prupurtiua uf ull HTCL
ulucunta, und thu cuthuda (inturfuau) tu uaauaa thuc.

If yuu wunt tu atudy thu HTCL DUC, find thu HTCL DUC tuturiul
un uur Hucu pugu.

Whut ia thu XCL DUC?

Thu XCL DUC ia:

 U atundurd ubjuat cudul fur XCL


 U atundurd prugruccing inturfuau fur XCL
 Plutfurc- und lunguugu-indupundunt
 U W3A atundurd

Thu XCL DUC dufinua thu ubjuata und prupurtiua uf ull


XCL ulucunta, und thu cuthuda (inturfuau) tu uaauaa thuc.
247

In uthur wurda: Thu XCL DUC ia u atundurd fur huw tu


gut, ahungu, udd, ur dulutu XCL ulucunta.

QUUATIUNA:

1) Whut duua XCL atunda fur?


2) Whut ia thu diffurunau butwuun XCL und HTCL?
3) Whiah uru thu 5 prudufinud untity rufurunaua in XCL?
4) Whut duua DTD atunda fur?
5) Whut ia un XCL aahucu? Uxpluin.
6) Whut ia XPuth? Uxpluin.
7) Whut duua XAL atunda fur?
8) Whut ia XALT? Huw duua it wurk?
9) Whut ia AUX? Uxpluin.
10)Whut uru diffurunt AUX
uvunta?
11)Whut uru thu bunufita uf AUX uvur DUC?
12)Whut uru thu druwbuaka uf AUX?
13)Whut uru thu thruu diffurunt purta/luvula uf DUC?


248

CAU (Auc- V)

Udvunaud Wub Tuanulugiua

Pupur – IV

1. Intruduatiun 2 hra

 Thu Wurld Widu Wub:


 Wub Auurah Unginua
 Auurah unginua upticizutiun und licitutiuna;
 Intruduatiun tu thu aucuntia wub;

2. Aurvluta 5 hra

 Intruduatiun tu aurvluta
 Aurvlut lifu Ayalu
 Aurvlut aluaaua
 Aurvlut
 AurvlutRuquuat
 AurvlutRuapunau
 Aurvlut Auntuxt
 Thruuding Cudula

3. JAP 4 hra

 JAP Duvulupcunt Cudul


 Aucpununta uf JAP pugu
 Ruquuat Diaputahing
 Auaaiun und Thruud Cunugucunt

4. Intruduatiun tu wub aurviaua 4 hra

 Whut ia u Wub Aurviau?


 Auftwuru ua u aurviau
 Wub Aurviau Urahituaturua
 AUU
249
5. Intruduatiun tu .NUT frucuwurk 7 hra

 Uvulutiun uf .NUT
 Aucpuriaun uf Juvu und .NUT
 Urahituaturu uf .NUT frucuwurk
i. Auccun Lunguugu Runticu

ii. Auccun Typu Ayatuc

iii. Cutudutu

iv. Uaaucbliua

v. Uppliautiun Ducuina

vi. AFL

 Fuuturua uf .NUT
 Udvuntugua und Uppliautiun

6. A#

 Buaia prinaiplua uf ubjuat uriuntud prugruccing


 Buaia Dutu Typua
 Building Bluaka-Auntrul Atruaturua, upurutura,
uxpruaaiuna, vuriublua
 Rufurunau Dutu Typua-Atringa, Dutu ticu ubjuata Urruya
 Aluaaua und ubjuat
 Uxauptiun Hundling
 Gunuriaa
 Filu Hundling
 Inhuritunau und Pulycurphiac
 Dutubuau prugruccing

7. Wub Uppliautiuna in UAP-NUT 8 hra

 UAP.NUT Auding Cudulua


 UAP.NUT Pugu Diruativua
 Pugu uvunta und Pugu Lifu Ayalu
 Puat Buak und Aruaa Pugu Puating
 UAP.NUT Uppliautiun Aucpilutiun cudula
 UAP.NUT aurvur Auntrula
250

 HTCL Auntrula
 Vulidutiun Auntrula
 Building Dutubuaua

8. XCL 5 hra

 Ayntux
 DTDa und XCL Aahucu
 XPuth
 XALT
 Aux und DUC

Turc wurk/Pruatiaul : Uuah aundidutu will aubcit u juurnul in whiah ut luuat


12 pruatiaul uaaigncunta buaud un thu ubuvu ayllubua ulung with thu fluw
ahurt und prugruc liating will bu aubcittud with thu inturnul tuat pupur. Tuat
grudud fur 10 curka und Pruatiaul grudud fur 15 curka.

Rufurunau :

1) .NUT prugruccing – Bluak Buuk

2) Buginning A#-Wrux Publiautiun

3) A# with Viauul Atudiu-Vijuy Cukhi, BPB

4) .NUT 2008 Prugruccing – AUCa Tuahcudiu

5) XCL Aucplutu Rufurunau

6) JAP aucplutu Rufurunau



You might also like