基于Java技术的Web应用设计模型的比较研究.docx
- 文档编号:8178998
- 上传时间:2023-01-29
- 格式:DOCX
- 页数:17
- 大小:80.16KB
基于Java技术的Web应用设计模型的比较研究.docx
《基于Java技术的Web应用设计模型的比较研究.docx》由会员分享,可在线阅读,更多相关《基于Java技术的Web应用设计模型的比较研究.docx(17页珍藏版)》请在冰豆网上搜索。
基于Java技术的Web应用设计模型的比较研究
3690单词,19100英文字符,5763汉字
出处:
KurniawanB,XueJ.AComparativeStudyofWebApplicationDesignModelsUsingtheJavaTechnologies.[J].LectureNotesinComputerScience,2004,3007:
711-721.
外文文献资料
AComparativeStudyofWebApplicationDesignModels
UsingtheJavaTechnologies
KurniawanB,XueJ
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,theFacesServletconstructsacomponenttreethatrepresentstheJSPpagebeingreque
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于 Java 技术 Web 应用 设计 模型 比较 研究
![提示](https://static.bdocx.com/images/bang_tan.gif)