英文技术文献 jsp.docx

上传人:b****5 文档编号:12310092 上传时间:2023-04-18 格式:DOCX 页数:15 大小:29.12KB
下载 相关 举报
英文技术文献 jsp.docx_第1页
第1页 / 共15页
英文技术文献 jsp.docx_第2页
第2页 / 共15页
英文技术文献 jsp.docx_第3页
第3页 / 共15页
英文技术文献 jsp.docx_第4页
第4页 / 共15页
英文技术文献 jsp.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

英文技术文献 jsp.docx

《英文技术文献 jsp.docx》由会员分享,可在线阅读,更多相关《英文技术文献 jsp.docx(15页珍藏版)》请在冰豆网上搜索。

英文技术文献 jsp.docx

英文技术文献jsp

Thetitleofthebook:

《JavaServerPagesTM,ThirdEdition》.

Author:

HansBergsten.

Press:

O’ReillyMedia,Inc.

Source:

.

Chapter18.WebApplicationModels

PartIIofthisbookdescribeshowyoucancreatemanydifferenttypesofapplicationsusingonlyJSPpageswithgenericcomponents—JSTLactions,customactionsandbeans—toaccessdatabases,presentcontentindifferentlanguages,protectpages,andsoforth—allwithoutknowingmuchaboutJavaprogramming.Thisapproachworksfineformanytypesofwebapplications,suchasemployeeregisters,productcatalogs,andconferenceroomreservationsystems.Butforapplicationswithcomplicatedschemas,intricatebusinessrules,andtrickycontrolflows,thegenericcomponentsjustdon'tcutit,andyousuddenlyfindthatyouneedamorepowerfulwaytohandletherequestprocessingandthebusinesslogic.

AsImentionedinChapter3,JSPcanbecombinedwithotherJavatechnologiessuchasservletsandEJBinmorecomplexapplications.Inthischapter,welookathowJSPfitsintothislargerpicture.Afterthebriefdescriptionofthemostcommonapplicationmodelsinthischapter,Chapter19describesthecombinationofservletsandJSPindetail.

ThematerialpresentedinthispartofthebookisgearedtowardsJavaprogrammers.Ifyou'renotaprogrammer,youmaystillwanttobrowsethroughthisparttogetafeelforthepossibilities,butdon'texpecttounderstandeverything.Toreallyappreciatethetechniquesdescribedinthispartofthebook,youshouldhaveexperiencewithJavaprogrammingingeneral.FamiliaritywithJavaservletsalsohelps,andashortintroductionisincludedinChapter19forthosewhoarenewtothistechnology.

18.1TheJava2EnterpriseEditionModel

AttheJavaOneconferenceinSanFranciscoinJune1999,SunMicrosystemsannouncedanewarchitectureforJava,withseparateeditionsfordifferenttypesofapplications:

theJava2StandardEdition(J2SE)fordesktopandworkstationdevices;theJava2MicroEdition(J2ME)forsmalldevicessuchascellphones,pagers,andPDAs;andtheJava2EnterpriseEdition(J2EE)forserver-basedapplications.

J2EEisacompilationofvariousJavaAPIsthathavepreviouslybeenofferedasseparatepackages;anApplicationProgrammingModel(APM)(alsoknownastheJ2EEBlueprints)thatdescribeshowtheycanallbecombined;andatestsuiteJ2EEvendorscanusetotesttheirproductsforcompatibility.J2EEhasgonethroughanumberofrevisionssince1999,andthelatestversion(J2EE1.4)includesthefollowingenterprise-specificAPIsamongothers:

∙JavaServerPages(JSP)

∙JavaServlet

∙EnterpriseJavaBeans(EJB)

∙JavaDatabaseConnection(JDBC)

∙JavaTransactionAPI(JTA)andJavaTransactionService(JTS)

∙JavaNamingandDirectoryInterface(JNDI)

∙JavaMessageService(JMS)

∙JavaIDLandRemoteMethodInvocation(RMI)

∙JavaAPIforXMLParsing(JAXP),JavaAPIforXML-basedRPC(JAX-RPC),SOAPwithAttachmentsAPIforJava(SAAJ),andJavaAPIforXMLRegistries(JAXR)

∙JavaMailandJavaBeansActivationFramework(JAF)

∙J2EEConnectorArchitecture(JCX)

∙JavaAuthenticationandAuthorizationService(JAAS)

∙JavaManagementExtensions(JMX)

Inaddition,alltheJ2SEAPIscanbeusedwhendevelopingaJ2EEapplication.TheseAPIscanbeusedinnumerouscombinations.ThefirstthreeJ2EEAPIs—EJB,JSP,andservlets—representdifferentcomponenttechnologies,managedbywhattheJ2EEdocumentscallcontainers.AwebcontainerprovidestheruntimeenvironmentforservletsandJSPcomponents,translatingrequestsandresponsesintostandardJavaobjects.EJBcomponentsaresimilarlyhandledbyanEJBcontainer.Don'tbefooledbythenamesimilaritybetweenJavaBeansandEnterpriseJavaBeans(EJB);theyarecompletelydifferentanimals.AJavaBeanscomponentisaregularJavaclass,followingafewsimplenamingconventions,whichcanbeusedbyanyotherJavaclass.AnEnterpriseJavaBeancomponent,ontheotherhand,mustbedevelopedincompliancewithawholesetofstrictrulesandworksonlyintheenvironmentprovidedbyanEJBcontainer.

ComponentsinthetwotypesofcontainerscanusetheotherJ2EEAPIstoaccessdatabases(JDBCandJTA/JTS)andotherEIStierapplications(JCX),authenticateusersandcontrolaccess(JAAS),locatevariousresources(JNDI),andcommunicatewithotherserverresources(JavaMail/JAF,JMS,JavaIDL,RMI,JAXP,JAX-RPC,SAAJandJAXR).Enterpriseapplicationsareoftendividedintoasetoftiers,andJ2EEidentifiesthree:

theclienttier,themiddletier,andtheEnterpriseInformationSystem(EIS)tier.ThemiddletiercanbefurtherdividedintothewebtierandtheEJBtier.Thislogicalseparation,withwell-definedinterfaces,makesitpossibletobuildscalableapplications.Initiallyoneormoretierscanberunningonthesamephysicalserver.Withincreaseddemands,thetierscanbeseparatedanddistributedovermultipleserverswithoutmodifyingthecode,justbychangingtheconfiguration.

TheclienttiercontainsbrowsersaswellasregularGUIapplications.AbrowserusesHTTPtocommunicatewiththewebcontainer.AstandaloneapplicationcanalsouseHTTPorcommunicatedirectlywiththeEJBcontainerusingRMIorIIOP(aCORBAprotocol).Anothertypeofclientthat'sbecomingmoreandmorepopularistheextremelythinclient,suchasacellphoneorPDA.ThistypeofclienttypicallyusestheWirelessAccessProtocol(WAP),typicallyconvertedintoHTTPviaagateway,tocommunicatewiththewebcontainer.

ThemiddletierprovidesclientservicesthroughthewebcontainerandtheEJBcontainer.AclientthatcommunicateswiththeserverthroughHTTPusescomponentsinthewebcontainer,suchasservletsandJSPpages,asentrypointstotheapplication.Manyapplicationscanbeimplementedsolelyaswebcontainercomponents.Inotherapplications,thewebcomponentsjustactasaninterfacetotheapplicationlogicimplementedbyEJBcomponents.Astandaloneapplication,writteninJavaoranyotherprogramminglanguage,canalsocommunicatedirectlywiththeEJBcomponents.Generalguidelinesforwhentousethedifferentapproachesarediscussedlaterinthischapter.ComponentsinthistiercanaccessdatabasesandcommunicatewithotherserverapplicationsusingalltheotherJ2EEAPIs.

TheEnterpriseInformationSystem(EIS)tierholdstheapplication'sbusinessdata.Typically,itconsistsofoneormorerelationaldatabasemanagementservers,butothertypesofdatabasessuchasIMSdatabases;legacyapplicationssuchasEnterpriseResourcePlanning(ERP);andmainframetransactionprocessingsystemssuchasCICS,arealsoincludedinthistier.ThemiddletierusesJ2EEAPIssuchasJDBC,JTA/JTS,andtheJ2EEConnectorArchitecture(JCX)tointeractwiththeEIStier.

18.2TheMVCDesignModel

Inadditiontotheseparationofresponsibilitiesintodifferenttiers,J2EEalsoencouragestheuseoftheModel-View-Controller(MVC)designmodel,brieflyintroducedinChapter3,whendesigningapplications.

TheMVCmodelwasfirstdescribedbyXeroxinanumberofpaperspublishedinthelate1980sinconjunctionwiththeSmalltalklanguage.ThismodelhassincebeenusedforGUIapplicationsdevelopedinallpopularprogramminglanguages.Let'sreview:

thebasicideaistoseparatetheapplicationdataandbusinesslogic,thepresentationofthedata,andtheinteractionwiththedataintodistinctentitieslabeledtheModel,theView,andtheController,respectively.

TheModelrepresentspurebusinessdataandtherulesforhowtousethisdata;itknowsnothingabouthowthedataisdisplayedortheuserinterfaceformodifyingthedata.TheView,ontheotherhand,knowsallabouttheuserinterfacedetails.ItalsoknowsaboutthepublicModelinterfaceforreadingitsdata,sothatitcanrenderitcorrectly,anditknowsabouttheControllerinterface,soitcanasktheControllertomodifytheModel.

Usinganemployeeregistryapplicationasanexample,anEmployeeclassmayrepresentaModel.Itholdsinformationaboutanemployee:

name,employmentdate,vacationdays,salary,etc.Italsoholdsrulesforhowthisinformationcanbechanged;forinstance,thenumberofvacationdaysmaybelimitedbasedontheemploymenttime.TheuserinterfacethatshowstheinformationisaView.ItgetsholdofanEmployeeobjectbyaskingtheControllerforitandthenrenderstheinformationbyaskingtheEmployeeobjectforitspropertyvalues.TheViewalsorenderscontrolsthatallowtheusertomodifytheinformation.TheViewssendsthemodificationrequesttotheController,whichupdatestheEmployeeobjectandthentellstheViewthattheModelhasbeenmodified.TheView,finally,updatestheuserinterfacetodisplaytheupdatedvalues.

UsingtheMVCdesignmodelmakesforaflexibleapplicationarchitecture,inwhichmultiplepresentations(Views)canbeprovidedandeasilymodified,andchangesinthebusinessrulesorphysicalrepresentationofthedata(theModel)canbemadewithouttouchinganyoftheuserinterfacecode.

EventhoughthemodelwasoriginallydevelopedforstandaloneGUIapplications,ittranslatesfairlywellintothemultitierapplicationdomainofJ2EE.TheuserinteractswiththeControllertoaskforthingstobedone,andtheControllerrelaystheserequeststotheModelinaclient-typeindependentway.Say,forinstance,thatyouhavetwotypesofclients:

anHTTPclientsuchasabrowserandaGUIclientapplicationusingIIOPtotalktotheserver.InthisscenarioyoucanhaveoneControllerforeachprotocolthatreceivestherequestsandextractstherequestinformationinaprotocol-dependentmanner.BothControllersthencalltheModelthesameway;theModeldoesn'tneedtoknowwhatkindof

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 职业规划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1