Advance Java A:sig"mext 1
Anlkus Rawat
o12 148o7222
cSE- (SO-1
)
Code:
impoyt java. vtil.A sray ist,
mpott [Link]. L's ti
class EmYoll ment xcep tion ektends EKeption d
publit £nsollment Excep tion (String message)4
super Cmesage);
class Couxse Q
private String CouTSe Code;
priva te nax la pacity)
private List < student entoll ed students
public Course ( sting Cousse Iel, jnt max
Capicity)4
Hu's co sTse Code : Course Id:
Hh's. nax Capiity : max apieity;
th'[Link] Stuclents = new ArTy lis te ))
}
ox public voiel enToll Stu dont ls tucont stuclent) throt
Enollnent Ctceptiom
Censolle d Stucend .sizet) >nas lapic'ty ) 4
thzow new Cnsollnetlxceptien E" mar Capici'ty eache)
Cstudet); }
ele i cn sollecl Stucent-ade
class Studeat f
private Stsig name
privatt t Td
putie stucdent Cstring na me,i t Jl)
[Link] : na e)
publie Class UwivessitySystem f
publie statie void main(String () args)4
Student stulent l : new Stuclent ( "An Run 12)
s tuclont student2 > news Stuclod l " Ajay ", i);
Couse Complousie Cousse C" Conplol"', 1);
Cs tuclent l):
Comp louzse .cnToll Stu clent
Stucest Cs tu clent 2) :
(omp lou tse. en to ll
} cath ( Ensolmet Excep tien e)
tr'on:" + e
Syste [Link] pritln (" Snsellm ewt Cxcep
2)
Import [Link] t. Appletjc)
import [Link]. lo lotj
inport [Link]. araphs,t
im povt Yawaawt. evet. Atien Svent'
'nport [Link]. evewt. Ati'on lis teher ;
oublic class Aw'ntel App let cxte ncla App let inplemena Aeti'on lis texeyJ
privato Thseas Automatien Threacl;
vat boo lkam is Aim atng:
privat I't xposit lon
prives nt aw'maten speed ;
publie voil it)4
xposition z 0;
aw'mabon Speed : lo;
3
publie void start ) f
i Awimaliy True;
aw'mat'en hseael . stast C):
publie vo id stepOf
iSAiwati'ng : false
awmatonThread : null,
PublitVoi9 awmat, ()
wtile Cis Animating)
xpositon t:s
depaint C);
[Link] Cawimatierspeel);
}cth C In tersup ted Ikeption el{
e-psits tack TreteJ;
publie void pa'wl asaphyg) 1
9setlolbxClolorBlua)
9 l ovl ( xponition, Se, 3e, 3o);
putlie vo ig acti'er Pespernet CAtienfVe nt e)4
C;
string Co mmarel : e get Atten Co nmanl
("s tayt", e guado Ctomnand) ) i
start);
deyl" stop ".canasltommand) ) 4
stop ()
3) vario ut inuytie fon b'lcli'ny
cyucial in
Soc kt p7og damg is
syabn
uent and statle , JeMable metwosleel
inelude oline gamig,ina nwal trodng plaford,
Lxanple congy
chat applikatio ard bitibts ystn in cloel
J java provide a
c way to c3eat web
The Seavlet 9ntesface in Coponen at Tes po nel
app licato . Sev v lei ase server Siele
to Tegust fsom web d'ent, typicaly G30wSers.
the servlet ie yle Con'sts of three main Stuges:
9nitialization
y 9+ occuss when the Sez vlet is loacleel
methocl i's callecl dusing Hu's sto
he xe you lan pexorm onetme aci tgy
Tus i's
Sesvice Handlig :
y The servieC) method i'scalleclpan eaeh client sc uest.
9+ han de the actual proe'ng gf the seguest.
94') Lrucial to wgi te vet anel thr eacl sale coel i
Service C) methol
Des tyue tion:
The 'detsoy C)? methol 's callel hen the servlet i's beine
talen ot e sesv'ce
9 9+ alotthe sesvl2t to 3eleae avdl
desous Let an pefom
cleanup atuitid.
S) [Link] keeption;
impost [Link]. Psitwsitex
mport avax servlet.
Session Tyac kiitg Servlet ex tenls HTtp se rvlet {
publie clas fervlet ReipaMi e,
protectat vaid do aet C Hotp ser vletRegas req, HHp then {
tio", Io Exkep
Yes) thsowt Serv let Cxtep
sSibnCtrue):
HttpSessi'on Sessi'on = reg- got Se
luxeIna Me" "Aw kun)
Ser sv'[Link] Att 'buto
nes Coo kel "sesiionIl ' fes 3io gtId);
Coo hie scsSiov Id look'e :
aes. adel Coo kie Csess t'om Tel Coo wie);:
Psint writes Outet podeygetw ter J
[Link] C"chtnds cbody mao: </h)
Ch2 Sess ion 9nfo
<ps sess 'on Iel: + Session get Id O+"clp S
</6aeyc/h+m|3 ");
AlHesnaive sess ion Tsac Ko'e lechaw's e.
UAL Rewitiy : Appengdi'y tha Sessisn Id to UA L, safal
wten co o k's ase di'sablecl.
Ieina deon dormele.
Hdelen form Fieles: storing Sessi'on
track seJSram
SsL/TLs Sess i'on Ll: Utilluy sene conneetons to
Cuatom Header : Aldiy a custom kealer to kTP Reqeet
6) 9n Tava, beans are classe thet cn cafsulato many objecty
typo a bcany:
objeet. Here ae
singe objeet.
into a Single
PoJo (P lan old Java Objeet):
sinple Java ClaJdes wtt privato telhs publie get angl
Seten. mettocl
HTaa Bean:
9A speal ty Wend po Jo tha followd namy
Con ventons or psogez tie an methot
Poimaiy wied in basaul app lizato on eoy 9ntgraton.
6) n tevpuise Java Be oe CE JB):
Server Side Component model fo Jawe EE l entespxis e IlHon)
USedfoa mglemet'y bus inas logt in a dis taibukd eHv
d) na agel Beam.
9 Part o Jva Ser ven Face CJS F) frama woH