Web应用中英文对照外文翻译文献.docx
《Web应用中英文对照外文翻译文献.docx》由会员分享,可在线阅读,更多相关《Web应用中英文对照外文翻译文献.docx(22页珍藏版)》请在冰豆网上搜索。
Web应用中英文对照外文翻译文献
Web应用中英文对照外文翻译文献
(文档含英文原文和中文翻译)
外文:
AComparativeStudyofWebApplicationDesignModels
UsingtheJavaTechnologies
Abstract.
TheServlettechnologyhasbeenthemostwidelyusedtechnologyforbuildingscalableWebapplications.Intheevents,therearefourdesignmodelsfordevelopingWebapplicationsusingtheJavatechnologies:
Model1,Model2,Struts,andJavaServerFaces(JSF).Model1employsaseriesofJSPpages;Model2adoptstheModel-View-Controllerpattern;StrutsisaframeworkemployingtheModel2designmodel;andJSFisanewtechnologythatsupportsready-to-usecomponentsforrapidWebapplicationdevelopment.Model1isnotrecommendedformedium-sizedandlargeapplicationsasitintroducesmaintenancenightmare.Thispapercomparesandevaluatestheeaseofapplicationdevelopmentandtheperformanceofthethreedesignmodels(Model2,Struts,andJSF)bybuildingthreeversionsofanonlinestoreapplicationusingeachofthethreedesignmodels,respectively.
1Introduction
Today,Webapplicationsarethemostcommonapplicationsforpresentingdynamiccontents.ThereareanumberoftechnologiesforbuildingWebapplications,themostpopularofwhichistheServlettechnology.ThistechnologygainsitspopularityfromitssuperiorityoverothertechnologiessuchasCGIandPHP.Servletsarecumbersometodevelop,however,becausesendingHTMLtagsrequirestheprogrammertocomposethemintoaStringobjectandsendthisobjecttothebrowser.Also,aminorchangetotheoutputrequirestheservlettoberecompiled.Toaddressthisissue,SunMicrosystemsinventedJavaServerPages(JSP).JSPallowsHTMLtagstobeintertwinedwithJavacodeandeachpageistranslatedintoaservlet.AJSPpageisaservlet.However,compilationoccursautomaticallywhenthepageisfirstrequested.Asaresult,changingtheoutputdoesnotneedrecompilation.Inaddition,JSPenablestheseparationofpresentationfromthebusinesslogicthroughtheuseofJavaBeansandcustomtaglibraries.ThenormnowindevelopingJavabasedWebapplicationsistouseservletsalongwithJavaServerPages.
Inthelaterdevelopment,thereareanumberofdesignmodelsforbuildingservlet/JSPapplications:
Model1,Model2,Struts,andJSF.Model1andModel2werefirstmentionedintheearlyspecificationsofJSP.Model1strictlyusesJSPpages,withnoservlets,andModel2usesthecombinationofbothservletsandJSPpages.ThetermsofModel1andModel2havebeenusedeversince.Model1issuitableforprototypesandverysmallapplications,andModel2istherecommendeddesignmodelformediumsizedandlargeapplications.
AsModel2gainedmoreacceptancesintheindustry,anopensourceinitiativetobuildtheStrutsFrameworkwasinitiated.StrutsperfectsModel2byprovidingthecontrollerpartoftheModel-View-ControllerofModel2.Inaddition,Strutsprovidesbetterpagenavigationmanagementandseveralcustomtaglibrariesformorerapiddevelopment.Despiteitssteeplearningcurveandthefactthatitwasneverdefinedinanyspecification,StrutshasbeengainingpopularityasthealternativetoModel2.
JavaServerFacesisbuiltundertheJavaCommunityProcessunderJSR-127.SunMicrosystemsproposedthistechnologyinthehopethatJSFwillbetheultimatemodelforbuildingJavaWebapplications.ThemostimportantfeatureofJSFistheavailabilityofready-to-usecomponentssuchasextensibleUIcomponents,easypagenavigation,inputvalidators,dataconvertersandJavaBeansmanagement.
Theproblemfacingservlet/JSPprogrammersaretochoosethemostappropriatedesignmodel.Clearly,JSFprovidesabettersolutioninregardtodevelopmenttime.However,somepeoplearenotsanguinetoadoptthistechnologyforfearofperformancepenaltyduetotheoverheadoftheJSFimplementation.
WebuildthreeversionsofanonlinestoreapplicationnamedBuyDirectusingModel2,StrutsandJSF.Theparameterscomparedarethenumberoflinesofcode,thenumberofclasses,andtheperformancemeasurementresults.Weinvestigatewhichofthedesignmodelsallowsthemostrapiddevelopmentprocess.Weevaluatetheperformancesoftheapplicationsbuiltuponthesemodels.Weprovidesomesuggestionstoperfecttheexistingdesignmodelstomakedevelopmentmorerapid.
Therestofthepaperisorganisedasfollows.Section2discussestheissuesinWebdevelopment.Section3explainshowthethreedesignmodelsaddressthesedevelopmentissues.Section4providesthedetailsofthehardwareandsoftwareusedintheseexperiments.Section5presentstheexperimentresultsandanalysis.Section6reviewstherelatedwork.Section7concludesbyofferingsomesuggestionstoimprovetheexistingdesignmodels.
2JavaWebDevelopmentIssues
AllJavaWebdevelopmentusestheServlettechnologyastheunderlyingtechnology.Assuch,allJavaWebapplicationshavecertainissuesthatneedtobeaddressed:
●UserInterface.TheuserinterfaceiswhattheclientbrowserrendersasHTMLtags.Anyserver-sidecomponentusedintheapplicationmustbeencodedintothecorrespondingHTMLelements.Besidesfordisplayingthecontentanddata,theuserinterfaceisalsoresponsibleinreceivinginputfromtheuser.
●InputValidation.Userinputneedstobevalidated.Therearetwotypesofinputvalidation,server-sideandclient-side.Asthenameimplies,theserver-sideinputvalidationisperformedontheserveraftertheinputreachestheserver.Client-sideinputvalidationisdoneonthebrowser,usuallybyusingJavaScriptorotherscriptinglanguages.Theadvantagesofusingclient-sideinputvalidationarepromptresponseandreducingtheserverworkload.Theserver-sideinputvalidationshouldalwaysbeperformedregardlessthepresenceofclient-sidevalidationbecausethereisnoguaranteetheuserbrowser'sscriptingfeatureisbeingonandmalicioususerscaneasilyworkaroundclient-sidevalidation.
●ModelObjects.ModelobjectsinJava-basedWebapplicationsareintheformsofJavaBeans.ModelobjectsmakeuptheModelpartoftheMVCbaseddesignmodel.Amodelobjectcanbeusedtobindacomponentvaluetobeusedatalaterstage.Inaddition,itcanencapsulatebusinesslogicrequiredforprocessing.
●PageNavigation.AlmostallWebapplicationshavemultiplepagesthattheusercannavigatefromonetoanother.AllMVC-baseddesignmodelsuseaservletastheControllerpart.Thisservletalsoactsasthesoleentrypointtotheapplication.Whichpagetobedisplayedafterthecurrentrequestisdeterminedbythevalueofaspecifiedrequestparameter.Managingpagenavigationiscriticallyimportant.
3WebApplicationDesignModels
TheModel2designmodelisbasedontheModel-View-Controller(MVC)designpattern.AsexplainedbyBurbeck,therearethreemainmodulesinMVC,theController,theView,andtheModel.TheControlleractsasthecentralentrypointtotheapplication.Alluserinteractionsgothroughthiscontroller.TheViewcontainsthepresentationpartoftheapplication,andtheModelstoresdataorencapsulatesbusinesslogicoftheapplication.Inthelaterdevelopment,theStrutsFrameworkprovidesacommonframeworktoeasilybuildModel2applications.Then,thelastinitiativeistheJavaServerFaces,whichalsoemploystheMVCdesignpattern.
Inthefollowingsections,wediscussthesethreedesignmodelsandexplainhoweachdesignmodeladdressesthedevelopmentissuesspecifiedintheprevioussection.
3.1Model2
AJavaWebapplicationthatisbasedontheModel2designmodelhasoneservlet(calledtheControllerservlet)thatservesastheControllerpart.Allrequestsarefirsthandledbythisservlet,whichimmediatelydispatchestherequeststotheappropriateviewsusingRequestDispatcherobjects.ViewsintheModel2designmodelarerepresentedbyJSPpages.Tostoredata,aModel2applicationusesJavaBeans,whicharetheModelpartoftheapplication.Inadditiontostoringdata,theJavaBeansalsoencapsulatebusinesslogic.EachHTTPrequestcarriesanactionparameterthatindicateswhichviewtodispatchthisrequestto.TheprogrammermustcodetheHTMLtagsforuserinterfaceinallJSPpagesintheapplicationandwriteinputvalidationcode.Inaddition,themodelobjectsaremanagedbyindividualJSPpages.
3.2Struts
TheStrutsFrameworkisanimprovementoftheModel2designmodel.ItprovidesadefaultControllerservletsothattheuserdoesnothavetowriteandcompileone.Strutsalleviatesthetaskofpagenavigationbyallowingnavigationrulestobepresentinitsapplicationconfigurationfile(anXMLdocument).ChangestothenavigationrulesdonotrequirerecompilationofaJavaservletclass.Inadditiontoeasierpagenavigation,StrutsprovidescustomtaglibrariesthatdefinetagsrepresentingHTMLelements.OneofthesetagsisusedforerrorhandlingandStrutsisthereforecapableofdisplayinglocalizederrormessagesinsupportforinternationalization.StrutsapplicationsuseJavaBeansastheirmodels,justliketheModel2designmodel.Inaddition,Strutsprogrammershavetowritetheirowninputvalidationcode.
3.3JSF
JSFalsoemploysacontrollerservletthatiscalledFacesServlet.ThisservletistheonlyentrypointtoaJSFapplication.JSFalsousesJSPpagesasitsviewsandJavaBeansasitsmodelobjects.UnlikeModel2andStruts,however,JSFprovidesready-to-useuserinterfacecomponentsthatcanbewrittenonJSPpages.UponaninvocationofapageofaJSFapplication,theFacesServletconstructsacomponenttreethatrepresentstheJSPpagebeingrequested.Someofthecomponentscanalsotriggerevents,makingJSFevent-driven.Forpagenavigation,JSFusesanapproachsimilartoStruts,i.e.,byallowingnavigationrulestobede