软件外文翻译.docx
- 文档编号:3010244
- 上传时间:2022-11-17
- 格式:DOCX
- 页数:8
- 大小:23.68KB
软件外文翻译.docx
《软件外文翻译.docx》由会员分享,可在线阅读,更多相关《软件外文翻译.docx(8页珍藏版)》请在冰豆网上搜索。
软件外文翻译
软件外文翻译
XMLandJavaServerPages
Authors:
Papadias,Dimitris,Egenhofer,MaxJ.
From:
《Geoinformatica》vol.1,no.3p.251-254December2009
JavaServerPages(JSP)technologyistypicallyusedforbuildingHTMLpageswithdynamiccontent.Butyoucanusethistechnologytogeneratedynamiccontentinotherformatsaswell,includingXML.Usingrealexamples,thisarticlewillshowhowtobuildaJSPpageasanXMLdocumenttemplatethatis"filledin"atrequesttimeusingJavacodeembeddedinthepage.
WebapplicationdeveloperstraditionallyhaveusedJSPtechnologytobuildHTMLdynamicallybyincludingJavacodeintheHTMLsource.ButdidyouknowthatyoucanusethissameapproachtogeneratedynamiccontentbesidesHTML?
Youcan,andit'srelativelysimple.YoucanbuildaJSPpageusinganXMLdocumentthatwillserveasthetemplatefortheoutput,thenreplacetheportionsthatmustbegenerateddynamicallybasedontheunderlyingbusinesslogic.YouuseJavacode,eitherwrittendirectlywithintheJSPpageorcalledexternallyfromthepage,togeneratethedynamicportionsofthedocument.
Youareincontrolofhowmuchofthatdocumentisgenerated.Forexample,youcanuseJavacodetogeneratedatabetweenXMLtags,togenerateportionsoftheXMLdocumenttree(bothtagsanddata),oreventogeneratetheentiredocument.
TheJavacodeisremovedfromthepage,processedintoaservlet(knownasthepageservlet)andrunbytheJavaapplicationserveraspartoftherequestfortheJSPpage.TheresultispureXML.
1.TheJSPtechnologyoverview
Let'sbeginbytalkingalittleabouthowJSPpageswork.We'regoingtokeepitsimpleandfocusonsomeofthebasics.Formoreinformation,seeResourcesforlinkstoadditionalJSPtechnologyinformation.
Inthetraditionalsense,JSPpageslookverymuchlikeHTMLpages,withafewextratags.ThesetagsallowthedesignertoembedJavacode(notJavaScript)inthepageitself.AWebapplicationserver,liketheIBMWebSphereApplicationServer,willinterceptrequestsforJSPpages.It'stippedofftotheirexistencebythepage'sextension:
.jsp(not.html).TheWebapplicationserverthenpreprocessestheJSPpage,takingouttheJSPtagsandanyembeddedJavacode,leavingonlytheHTML.TheextractedJSPtagsandembeddedJavacodeareusedtobuildaJavaservlet(JSPpageservlet)thatrunsthecodeandinsertstheresultsbackintotheoriginalpagewheretheJSPtagsusedtobe.TheresultispureHTML.TheJavaisstrippedoutandrunontheserverbeforetherequestingbrowserseesanyresult.
WecanapplythesameprincipletoanXMLpage.BeforetherequesteroftheJSPpagecontainingXMLeverseestheXML(beitabrowserorsomeotherB2Bapplication),theJavacodeisstrippedoutoftheJSPpageandusedtogenerateadditionalcontent,whichisinsertedbackintothepageatthepointswheretheJSPtagsusedtoreside.Thisfeaturegivesyoutheabilitytocontrolexactlywherenewcontentistobeinserted,downtothecharacter.
We'lllookathowtomakethisworkinaminute.First,let'sconsiderwhyyoumightwanttocreatedynamicXMLusingJSP.WhynotsimplywriteaJavaapplicationorservlettogeneratetheentiredocument?
WhybotherwithJSPatall?
Themostimportantreason,
1
providingonlyportionsofanXMLdocumentaredynamic,isthatitmakessensenottoregeneratethatstaticcontentforeveryrequest.UsingaJSPpage,thestaticXMLwithinthepageactsasatemplatethatisfilledoutbythedynamiccontent.YourJavacodeistaskedwithgeneratingonlythecontentthatmightchangeovertime--amoreefficientapproach.
Asapracticalmatter,JSPpagesallowyoutoseparatetasksforwhichdifferentdeveloperswillberesponsible.Inparticular,theyallowyoutobetterseparatethedatafromtheview,allowingyoutoaddnewpresentationswithoutaffectingthelogic.ImaginehavingoneJavaservletthatperformsthebusinesslogicandredirectstheresultingdatatoanappropriateJSPpagebasedonthenatureoftherequest.Forexample,aservletmightredirectdatatoaJSPpagecontainingWMLwhenitdetectsaWAPphonebrowsermakingtherequest.ItcouldalsoredirectthedatatoaJSPpagecontainingHTMLforstandardbrowserrequests.Themechanics
Let'swalkthroughanexampleinwhichastaticXMLdocumentisconvertedtoJSPpage,andportionsofitscontentarerewrittentobedynamicallygenerated.TheexampleisbasedonanXMLsampleshippedaspartoftheIBMWebSphereTranscodingPublishercalledFlightInfo.ThisXMLdocumentrepresentsinformationaboutaspecificairlineflightitinerary.TranscodingPublisherprovidesitasasampletoshowhowtheproductcanbeusedtorendertheXMLdataindevice-appropriateformats.ButbeforeTranscodingPublisher,oranyotherapplication,hasachancetomanipulatethedocument,wewanttobuilds
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 软件 外文 翻译