资源描述:
《计算机毕设译文》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、┊┊┊┊┊┊┊┊┊┊┊┊┊装┊┊┊┊┊订┊┊┊┊┊线┊┊┊┊┊┊┊┊┊┊┊┊┊长春大学毕业设计(译文)纸InvokingJavaCodeWithJSPScriptingElements1CreatingTemplateTextInmostcases,alargepercentageofyourJSPdocumentconsistsofstatictext(usuallyHTML),knownastemplatetext.Inalmostallrespects,thisHTMLlooksjustlikenormalHT
2、ML,followsallthesamesyntaxrules,andissimply“passedthrough”totheclientbytheservletcreatedtohandlethepage.NotonlydoestheHTMLlooknormal,itcanbecreatedbywhatevertoolsyoualreadyareusingforbuildingWebpages.Forexample,weusedMacromediaDreamweaverformanyoftheJSPpagesint
3、hisbook.Therearetwominorexceptionstothe“templatetextispassedstraightthrough”rule.First,ifyouwanttohave<%or%>intheoutput,youneedtoput<%or%>inthetemplatetext.Second,ifyouwantacommenttoappearintheJSPpagebutnotintheresultantdocument,use<%--JSPComment--%>HTMLcomme
4、ntsoftheformarepassedthroughtotheclientnormally.2WhyBuildWebPagesDynamically?Manyclientrequestscanbesatisfiedbyprebuiltdocuments,andtheserverwouldhandletheserequestswithoutinvokingservlet.Inmanycases,however,astaticresultisnotsufficient,andapa
5、geneedstobegeneratedforeachrequest.ThereareanumberofreasonswhyWebpagesneedtobebuilton-the-fly:1.TheWebpageisbasedondatasentbytheclient.Forinstance,theresultspagefromsearchenginesandorder-confirmationpagesatonlinestoresarespecifictoparticularuserrequests.Youdon'
6、tknowwhattodisplayuntilyoureadthedatathattheusersubmits.Justrememberthattheusersubmitstwokindsofdata:explicit(i.e.,HTMLformdata)andimplicit(i.e.,HTTPrequestheaders).Eitherkindofinputcanbeusedtobuildtheoutputpage.Inparticular,itisquitecommontobuildauser-specific
7、pagebasedonacookievalue.2.TheWebpageisderivedfromdatathatchangesfrequently.Ifthepagechangesforeveryrequest,thenyoucertainlyneedtobuildtheresponseatrequesttime.Ifitchangesonlyperiodically,however,youcoulddoittwoways:youcouldperiodicallybuildanewWebpageontheserve
8、r(independentlyofclientrequests),oryoucouldwaitandonlybuildthepagewhentheuserrequestsit.Therightapproachdepends共9页第9页┊┊┊┊┊┊┊┊┊┊┊┊┊装┊┊┊┊┊订┊┊┊┊┊线┊┊┊┊┊┊┊┊┊┊┊┊┊长春大学毕业设计(译文)纸onth