英文技术文献 jsp文档格式.docx

上传人:b****2 文档编号:3118206 上传时间:2023-05-01 格式: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_第6页
第6页 / 共15页
英文技术文献 jsp文档格式.docx_第7页
第7页 / 共15页
英文技术文献 jsp文档格式.docx_第8页
第8页 / 共15页
英文技术文献 jsp文档格式.docx_第9页
第9页 / 共15页
英文技术文献 jsp文档格式.docx_第10页
第10页 / 共15页
英文技术文献 jsp文档格式.docx_第11页
第11页 / 共15页
英文技术文献 jsp文档格式.docx_第12页
第12页 / 共15页
英文技术文献 jsp文档格式.docx_第13页
第13页 / 共15页
英文技术文献 jsp文档格式.docx_第14页
第14页 / 共15页
英文技术文献 jsp文档格式.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

英文技术文献 jsp文档格式.docx

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

英文技术文献 jsp文档格式.docx

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-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2