Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.68 MB, 2 trang )
FinishingtheSite
Beforemovingon,thereareafewbitsandpiecesofthesitethatneedtobe
addressed.Thebulkofthesiteconsistsofthecustomcomponentspreviously
addressedbythischapter.Allofthecustomcomponentsrequiredcodingfrom
scratch.Nowweshalladdressseveralcomplementarycomponentsthatwere
demonstratedinpreviouschapters.Allthecomponentswillberelativelysimple
toimplement;insteadofcodingfromscratch,wewillsimplydeploypreviously
explainedcodelistings.
Thelistofthingstoimplementisasfollows:site-wideerrorhandling,security,
linktracking,caching,compression,andthesite'shiddenEasteregg.Eachofthe
componentswascompletelycoveredinpreviouschapters,buteachcomponent
isbrieflyrehashedinthefollowingsectionsasitisinstalledforusewiththe
booksupportsite.
Site-WideErrorHandling
Allofthecodepreviouslyprovidedforthebooksupportsiteusespropererror
handling;however,anerrorcanstillbethrown(althoughitprobablyneverwill)
bytheWebApplication.Shouldthishappen,thecontainerwillhavetohandle
theerror.Normally,aswithTomcat,astacktraceisprintedanddisplayedina
developer-friendlyfashion,meaningacrypticpageisshowntoauser.To
preventthisfromhappening,weneedtocreateaWebApplicationerrorpage.
You'llrecallinChapter4thatthistopicwasdiscussedatlength.Theerrorpage
needstobenothingmorethanasimpleJSPorServletthatisregisteredvia
web.xml.
Listing15-35showsasimpleerrorpage.
Listing15-35.error.jsp
[Viewfullwidth]
Anerrorhasoccurred.Informationabouttheproblemhasbeen
loggedandwillbehandledbyadministratorsassoonaspossible.If