jsp544洗衣店管理系統(tǒng)(ssh)論文_第1頁
jsp544洗衣店管理系統(tǒng)(ssh)論文_第2頁
jsp544洗衣店管理系統(tǒng)(ssh)論文_第3頁
jsp544洗衣店管理系統(tǒng)(ssh)論文_第4頁
jsp544洗衣店管理系統(tǒng)(ssh)論文_第5頁
已閱讀5頁,還剩46頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

Withtheincreasinglyperfectandlaundryservicecomplex,simpletextrecordsbeforeartificialmanagementwaynotonlytheefficiencyislow,andpronetoerrors,leddirectlytothemanagementcostincreases,dropinthequalityofservice.Becauseofthisartificialmanagementmodecannotadaptthedevelopmentofdemand,aintelligentmanagementsystemsoarisesatthehistoricmoment.Thispaperaccordingtothesoftwareengineeringspecifications,accordingtotheactualdemanddescribesthewholeprocessofsystemanalysisanddesign,anintelligentcleaner'smanagementsystem.Itspurposeistorealizethechargeinformationmanagementandinandoutoftheclothesrecordquicklyandretrieval,theoperationissimpleandsafe,improveworkefficiencyandquality。Inthissystem,theusercanforthecorrespondingfunctionaloperation.Administratorscanallmembersofinformationaswellassaveclothing,clothingandotherinformationfrommodificationandinquiresthe,thememberinformationmanagement,collectionclothingsinformationmanagement,takeclothinginformationmanagement,accordingtothetimeperiodforturnoverstatisticsetc.Function。系統(tǒng)的響應(yīng)時間:用戶登錄時系統(tǒng)響應(yīng)時間在2秒鐘左??煽啃院头€(wěn)定性要求:要具有實用性、界面美觀、操作簡單、條理清晰;應(yīng)用軟件與數(shù)據(jù)庫系統(tǒng)的設(shè)計要做到安全可靠,防止非法用戶的入侵。(1)會員信息實體E-R圖如圖1.1所示:(2)洗衣價格信息實體E-R圖如圖3.2所示:(3)收取衣物信息實體E-R圖如圖2.3所示(4)管理員信息E-R圖如圖3.7所示一個1:1聯(lián)系可以轉(zhuǎn)換為一個獨立的關(guān)系模式,也可以與任意一端對應(yīng)的關(guān)系模式合并;一個1:n聯(lián)系可以轉(zhuǎn)換為一個獨立的關(guān)系模式,也可以與n端對應(yīng)的關(guān)系模式合并;一個m:n聯(lián)系可以轉(zhuǎn)換為一個獨立的關(guān)系模式;一個多元聯(lián)系可以轉(zhuǎn)換為一個獨立的關(guān)系模式;具有相同碼的關(guān)系模式可以合并。J測試任何軟件產(chǎn)品都有兩種方法:如果已經(jīng)知道了產(chǎn)品應(yīng)該具有的功能,通過測試來檢驗是否每個功能都能正常使用;如果知道產(chǎn)品內(nèi)部工作過程,通過測試來檢驗產(chǎn)品內(nèi)部動作是否按規(guī)定正常進行。前一種方法稱為黑盒測試,后一種方法稱為白盒測試。對于軟件測試而言,黑盒測試法把程序看作一個黑盒子,完全不考慮程序的內(nèi)部結(jié)構(gòu)和處理過程。也就是說,黑盒測試是在程序接口進行的測試,它只檢查程序功能是否能正常使用,程序是否能適當?shù)慕邮蛰斎氲臄?shù)據(jù)并產(chǎn)生正確的輸出信息,程序運行過程中能否保持外部信息的完整性。黑盒測試又稱為功能測試。白盒測試法和黑盒測試法相反,它的前提是可以把程序看成裝在一個透明的白盒子里,測試者完全知道程序的結(jié)構(gòu)和處理算法。這種方法按照程序內(nèi)部的邏輯測試程序,檢測程序中的主要執(zhí)行通路是否都能按預定要求正確的工作。白盒測試又稱為結(jié)構(gòu)測試。通過單元測試,發(fā)現(xiàn)了系統(tǒng)中存在的一些錯誤和漏洞,將這些問題解決后,又對系統(tǒng)進行了集成測試。測試結(jié)果表明系統(tǒng)能達到所需要求,各部分測試都能達到理想結(jié)果。Aframeworkisareusable,semi-completeapplicationthatcanbespecializedtoproducecustomapplications[Johnson].Likepeople,softwareapplicationsaremorealikethantheyaredifferent.Theyrunonthesamecomputers,expectinputfromthesamedevices,outputtothesamedisplays,andsavedatatothesameharddisks.Developersworkingonconventionaldesktopapplicationsareaccustomedtotoolkitsanddevelopmentenvironmentsthatleveragethesamenessbetweenapplications.Applicationframeworksbuildonthiscommongroundtoprovidedeveloperswithareusablestructurethatcanserveasthefoundationfortheirownproducts.Aframeworkprovidesdeveloperswithasetofbackbonecomponentsthathavethefollowingcharacteristics:1.Theyareknowntoworkwellinotherapplications.2.Theyarereadytousewiththenextproject.3.Theycanalsobeusedbyotherteamsintheorganization.Frameworksaretheclassicbuild-versus-buyproposition.Ifyoubuildit,youwillunderstanditwhenyouaredone—buthowlongwillitbebeforeyoucanrollyourown?Ifyoubuyit,youwillhavetoclimbthelearningcurve—andhowlongisthatgoingtotake?Thereisnorightanswerhere,butmostobserverswouldagreethatframeworkssuchasStrutsprovideasignificantreturnoninvestmentcomparedtostartingfromscratch,especiallyforlargerprojects.Othertypesofframeworks:Theideaofaframeworkappliesnotonlytoapplicationsbuttoapplicationcomponentsaswell.Throughoutthisarticle,weintroduceothertypesofframeworksthatyoucanusewithStruts.TheseincludetheLucenesearchengine,theScaffoldtoolkit,theStrutsvalidator,andtheTilestaglibrary.Likeapplicationframeworks,thesetoolsprovidesemi-completeversionsofasubsystemthatcanbespecializedtoprovideacustomcomponent.Someframeworkshavebeenlinkedtoaproprietarydevelopmentenvironment.ThisisnotthecasewithStrutsoranyoftheotherframeworksshowninthisbook.YoucanuseanydevelopmentenvironmentwithStruts:VisualAgeforJava,JBuilder,Eclipse,Emacs,andTextpadareallpopularchoicesamongStrutsdevelopers.IfyoucanuseitwithJava,youcanuseitwithStruts.Enablingtechnologies:ApplicationsdevelopedwithStrutsarebasedonanumberofenablingtechnologies.ThesecomponentsarenotspecifictoStrutsandunderlieeveryJavawebapplication.AreasonthatdevelopersuseframeworkslikeStrutsistohidethenastydetailsbehindacronymslikeHTTP,CGI,andJSP.AsaStrutsdeveloper,youdon’tneedtobeanalphabetsoupguru,butaworkingknowledgeofthesebasetechnologiescanhelpyoudevisecreativesolutionstotrickyproblems.HypertextTransferProtocol(HTTP):Whenmediatingtalksbetweennations,diplomatsoftenfollowaformalprotocol.Diplomaticprotocolsaredesignedtoavoidmisunderstandingsandtokeepnegotiationsfrombreakingdown.Inasimilarvein,whencomputersneedtotalk,theyalsofollowaformalprotocol.Theprotocoldefineshowdataistransmittedandhowtodecodeitonceitarrives.WebapplicationsusetheHypertextTransferProtocol(HTTP)tomovedatabetweenthebrowserrunningonyourcomputerandtheapplicationrunningontheserver.ManyserverapplicationscommunicateusingprotocolsotherthanHTTP.Someofthesemaintainanongoingconnectionbetweenthecomputers.Theapplicationserverknowsexactlywhoisconnectedatalltimesandcantellwhenaconnectionisdropped.Becausetheyknowthestateofeachconnectionandtheidentityofeachpersonusingit,theseareknownasstatefulprotocols.Bycontrast,HTTPisknownasastatelessprotocol.AnHTTPserverwillacceptanyrequestfromanyclientandwillalwaysprovidesometypeofresponse,eveniftheresponseisjusttosayno.Withouttheoverheadofnegotiatingandretainingaconnection,statelessprotocolscanhandlealargevolumeofrequests.ThisisonereasonwhytheInternethasbeenabletoscaletomillionsofcomputers.AnotherreasonHTTPhasbecometheuniversalstandardisitssimplicity.AnHTTPrequestlookslikeanordinarytextdocument.ThishasmadeiteasyforapplicationstomakeHTTPrequests.YoucanevensendanHTTPrequestbyhandusingastandardutilitysuchasTelnet.WhentheHTTPresponsecomesback,itisalsoinplaintextthatdeveloperscanread.ThefirstlineintheHTTPrequestcontainsthemethod,followedbythelocationoftherequestedresourceandtheversionofHTTP.ZeroormoreHTTPrequestheadersfollowtheinitialline.TheHTTPheadersprovideadditionalinformationtotheserver.Thiscanincludethebrowsertypeandversion,acceptabledocumenttypes,andthebrowser’scookies,justtonameafew.Ofthesevenrequestmethods,GETandPOSTarebyfarthemostpopular.Oncetheserverhasreceivedandservicedtherequest,itwillissueanHTTPresponse.ThefirstlineintheresponseiscalledthestatuslineandcarriestheHTTPprotocolversion,anumericstatus,andabriefdescriptionofthestatus.Followingthestatusline,theserverwillreturnasetofHTTPresponseheadersthatworkinawaysimilartotherequestheaders.Aswementioned,HTTPdoesnotpreservestateinformationbetweenrequests.Theserverlogstherequest,sendstheresponse,andgoesblissfullyontothenextrequest.Whilesimpleandefficient,astatelessprotocolisproblematicfordynamicapplicationsthatneedtokeeptrackoftheirusers.(Ignoranceisnotalwaysbliss.CookiesandURLrewritingaretwocommonwaystokeeptrackofusersbetweenrequests.Acookieisaspecialpacketofinformationontheuser’scomputer.URLrewritingstoresaspecialreferenceinthepageaddressthataJavaservercanusetotrackusers.Neitherapproachisseamless,andusingeithermeansextraworkwhendevelopingawebapplication.Onitsown,astandardHTTPwebserverdoesnottrafficindynamiccontent.Itmainlyusestherequesttolocateafileandthenreturnsthatfileintheresponse.ThefileistypicallyformattedusingHypertextMarkupLanguage(HTML)[W3C,HTML]thatthewebbrowsercanformatanddisplay.TheHTMLpageoftenincludeshypertextlinkstootherwebpagesandmaydisplayanynumberofothergoodies,suchasimagesandvideos.Theuserclicksalinktomakeanotherrequest,andtheprocessbeginsanew.Standardwebservershandlestaticcontentandimagesquitewellbutneedahelpinghandtoprovideuserswithacustomized,dynamicresponse.DEFINITION:StaticcontentontheWebcomesdirectlyfromtextordatafiles,likeHTMLorJPEGfiles.Thesefilesmightbechangedfromtimetotime,buttheyarenotalteredautomaticallywhenrequestedbyawebbrowser.Dynamiccontent,ontheotherhand,isgeneratedonthefly,typicallyinresponsetoanindividualizedrequestfromabrowser.CommonGatewayInterface(CGI):ThefirstwidelyusedstandardforproducingdynamiccontentwastheCommonGatewayInterface(CGI).CGIusesstandardoperatingsystemfeatures,suchasenvironmentvariablesandstandardinputandoutput,tocreateabridge,orgateway,betweenthewebserverandotherapplicationsonthehostmachine.Theotherapplicationscanlookattherequestsenttothembythewebserverandcreateacustomizedresponse.Whenawebserverreceivesarequestthat’sintendedforaCGIprogram,itrunsthatprogramandprovidestheprogramwithinformationfromtheincomingrequest.TheCGIprogramrunsandsendsitsoutputbacktotheserver.Thewebserverthenrelaystheresponsetothebrowser.CGIdefinesasetofconventionsregardingwhatinformationitwillpassasenvironmentvariablesandhowitexpectsstandardinputandoutputtobeused.LikeHTTP,CGIisflexibleandeasytoimplement,andagreatnumberofCGI-awareprogramshavebeenwritten.ThemaindrawbacktoCGIisthatitmustrunanewcopyoftheCGI-awareprogramforeachrequest.Thisisarelativelyexpensiveprocessthatcanbogdownhigh-volumesiteswherethousandsofrequestsareservicedperminute.AnotherdrawbackisthatCGIprogramstendtobeplatformdependent.ACGIprogramwrittenforoneoperatingsystemmaynotrunonanother.Javaservlets:Sun’sJavaServletplatformdirectlyaddressesthetwomaindrawbacksofCGIprograms.First,servletsofferbetterperformanceandutilizationofresourcesthanconventionalCGIprograms.Second,thewrite-once,run-anywherenatureofJavameansthatservletsareportablebetweenoperatingsystemsthathaveaJavaVirtualMachine(JVM).Aservletlooksandfeelslikeaminiaturewebserver.Itreceivesarequestandrendersaresponse.But,unlikeconventionalwebservers,theservletapplicationprogramminginterface(API)isspecificallydesignedtohelpJavadeveloperscreatedynamicapplications.TheservletitselfissimplyaJavaclassthathasbeencompiledintobytecode,likeanyotherJavaobject.TheservlethasaccesstoarichAPIofHTTP-specificservices,butitisstilljustanotherJavaobjectrunninginanapplicationandcanleverageallyourotherJavaassets.Togiveconventionalwebserversaccesstoservlets,theservletsarepluggedintocontainers.Theservletcontainerisattachedtothewebserver.EachservletcandeclarewhatURLpatternsitwouldliketohandle.Whenarequestmatchingaregisteredpatternarrives,thewebserverpassestherequesttothecontainer,andthecontainerinvokestheservlet.ButunlikeCGIprograms,anewservletisnotcreatedforeachrequest.Oncethecontainerinstantiatestheservlet,itwilljustcreateanewthreadforeachrequest.JavathreadsaremuchlessexpensivethantheserverprocessesusedbyCGIprograms.Oncetheservlethasbeencreated,usingitforadditionalrequestsincursverylittleoverhead.Servletdeveloperscanusetheinit()methodtoholdreferencestoexpensiveresources,suchasdatabaseconnectionsorEJBHomeInterfaces,sothattheycanbesharedbetweenrequests.Acquiringresourceslikethesecantakeseveralseconds—whichislongerthanmanysurfersarewillingtowait.Theotheredgeoftheswordisthat,sinceservletsaremultithreaded,servletdevelopersmusttakespecialcaretobesuretheirservletsarethread-safe.Tolearnmoreaboutservletprogramming,werecommendJavaServletsbyExample,byAlanR.Williamson[Williamson].ThedefinitivesourceforServletinformationistheJavaServletSpecification[Sun,JST].JavaServerPages:WhileJavaservletsareabigstepupfromCGIprograms,theyarenotapanacea.Togeneratetheresponse,developersarestillstuckwithusingprintlnstatementstorendertheHTML.Codethatlookslike:out.println("<P>OnelineofHTML.</P>");out.println("<P>AnotherlineofHTML.</P>");isalltoocommoninservletsthatgeneratetheHTTPresponse.TherearelibrariesthatcanhelpyougenerateHTML,butasapplicationsgrowmorecomplex,JavadevelopersendupbeingcastintotheroleofHTMLpagedesigners.Meanwhile,giventhechoice,mostprojectmanagersprefertodividedevelopmentteamsintospecializedgroups.TheylikeHTMLdesignerstobeworkingonthepresentationwhileJavaengineerssweatthebusinesslogic.Usingservletsaloneencouragesmixingmarkupwithbusinesslogic,makingitdifficultforteammemberstospecialize.Tosolvethisproblem,Sunturnedtotheideaofusingserverpagestocombinescriptingandtemplatingtechnologiesintoasinglecomponent.TobuildJavaServerPages,developersstartbycreatingHTMLpagesinthesameoldway,usingthesameoldHTMLsyntax.Tobringdynamiccontentintothepage,thedevelopercanalsoplaceJSPscriptingelementsonthepage.ScriptingelementsaretagsthatencapsulatelogicthatisrecognizedbytheJSP.YoucaneasilypickoutscriptingelementsonJSPpagesbylookingforcodethatbeginswith<%andendswith%>.TobeseenasaJSPpage,thefilejustneedstobesavedwithanextensionof.jsp.WhenaclientrequeststheJSPpage,thecontainertranslatesthepageintoasourcecodefileforaJavaservletandcompilesthesourceintoaJavaclassfile—justasyouwoulddoifyouwerewritingaservletfromscratch.Atruntime,thecontainercanalsocheckthelastmodifieddateoftheJSPfileagainsttheclassfile.IftheJSPfilehaschangedsinceitwaslastcompiled,thecontainerwillretranslateandrebuildthepagealloveragain.ProjectmanagerscannowassignthepresentationlayertoHTMLdevelopers,whothenpassontheirworktoJavadeveloperstocompletethebusiness-logicportion.TheimportantthingtorememberisthataJSPpageisreallyjustaservlet.Anythingyoucandowithaservlet,youcandowithaJSP.JavaBeans:JavaBeansareJavaclasseswhichconformtoasetofdesignpatternsthatmakethemeasiertousewithdevelopmenttoolsandothercomponents.DEFINITIONAJavaBeanisareusablesoftwarecomponentwritteninJava.ToqualifyasaJavaBean,theclassmustbeconcreteandpublic,andhaveanoargumentconstructor.JavaBeansexposeinternalfieldsaspropertiesbyprovidingpublicmethodsthatfollowaconsistentdesignpattern.Knowingthatthepropertynamesfollowthispattern,otherJavaclassesareabletouseintrospectiontodiscoverandmanipulateJavaBeanproperties.TheJavaBeandesignpatternsprovideaccesstothebean’sinternalstatethroughtwoflavorsofmethods:accessorsareusedtoreadaJavaBean’sstate;mutatorsareusedtochangeaJavaBean’sstate.Mutatorsarealwaysprefixedwithlowercasetokensetfollowedbythepropertyname.Thefirstcharacterinthepropertynamemustbeuppercase.Thereturnvalueisalwaysvoid—mutatorsonlychangepropertyvalues;theydonotretrievethem.Themutatorforasimplepropertytakesonlyoneparameterinitssignature,whichcanbeofanytype.Mutatorsareoftennicknamedsettersaftertheirprefix.ThemutatormethodsignatureforaweightpropertyofthetypeDoublewouldbe:publicvoidsetWeight(Doubleweight)Asimilardesignpatternisusedtocreatetheaccessormethodsignature.Accessormethodsarealwaysprefixedwiththelowercasetokenget,followedbythepropertyname.Thefirstcharacterinthepropertynamemustbeuppercase.Thereturnvaluewillmatchthemethodparameterinthecorrespondingmutator.Accessorsforsimplepropertiescannotacceptparametersintheirmethodsignature.Notsurprisingly,accessorsareoftencalledgetters.Theaccessormethodsignatureforourweightpropertyis:publicDoublegetWeight()Iftheaccessorreturnsalogicalvalue,thereisavariantpattern.Insteadofusingthelowercasetokenget,alogicalpropertycanusetheprefixis,followedbythepropertyname.Thefirstcharacterinthepropertynamemustbeuppercase.Thereturnvaluewillalwaysbealogicalvalue—eitherbooleanorBoolean.Logicalaccessorscannotacceptparametersintheirmethodsignature.ThebooleanaccessormethodsignatureforanonpropertywouldbepublicbooleanisOn()ThecanonicalmethodsignaturesplayanimportantrolewhenworkingwithJava-Beans.OthercomponentsareabletousetheJavaReflectionAPItodiscoveraJavaBean’spropertiesbylookingformethodsprefixedbyset,is,orget.IfacomponentfindssuchasignatureonaJavaBean,itknowsthatthemethodcanbeusedtoaccessorchangethebean’sproperties.SunintroducedJavaBeanstoworkwithGUIcomponents,buttheyarenowusedwitheveryaspectofJavadevelopment,includingwebapplications.WhenSunengineersdevelopedtheJSPtagextensionclasses,theydesignedthemtoworkwithJavaBeans.ThedynamicdataforapagecanbepassedasaJavaBean,andtheJSPtagcanthenusethebean’spropertiestocustomizetheoutput.FormoreonJavaBeans,wehighlyrecommendTheAwesomePowerofJavaBeans,byLawrenceH.Rodrigues[Rodrigues].ThedefinitivesourceforJavaBeaninformationistheJavaBeanSpecification[Sun,JBS].Model2:The0.92releaseoftheServlet/JSPSpecificationdescribedModel2asanarchitecturethatusesservletsandJSPpagestogetherinthesameapplication.ThetermModel2disappearedfromlaterreleases,butitremainsinpopularuseamongJavawebdevelopers.UnderModel2,servletshandlethedataaccessandnavigationalflow,whileJSPpageshandlethepresentation.Model2letsJavaengineersandHTMLdeveloperseachworkontheirownpartoftheapplication.AchangeinonepartofaModel2applicationdoesnotmandateachangetoanotherpartoftheapplication.HTMLdeveloperscanoftenchangethelookandfeelofanapplicationwithoutchanginghowtheback-officeservletswork.TheStrutsframeworkisbasedontheModel2architecture.Itprovidesacontrollerservlettohandlethenavigationalflowandspecialclassestohelpwiththedataaccess.AsubstantialcustomtaglibraryisbundledwiththeframeworktomakeStrutseasytousewithJSPpages.Summary:Inthisarticle,weintroducedStrutsasanapplicationframework.WeexaminedthetechnologybehindHTTP,theCommonGatewayInterface,Javaservlets,JSPs,andJavaBeans.WealsolookedattheModel2applicationarchitecturetoseehowitisusedtocombineservletsandJSPsinthesameapplication.框架(framework)是可重用的,半成品的應(yīng)用程序,可以用來產(chǎn)生專門的定制程序。象人一樣,軟件應(yīng)用的相似性比不同點要多。它們運行在相似的機器上,期望從相同的設(shè)備輸入信息,輸出到相同的顯示設(shè)備,并且將數(shù)據(jù)存儲到相同的硬盤設(shè)備。開發(fā)傳統(tǒng)桌面應(yīng)用的開發(fā)人員更習慣于那些可以涵蓋應(yīng)用開發(fā)同一性的工具包和開發(fā)環(huán)境。構(gòu)架在這些公共基礎(chǔ)上的應(yīng)用框架可以為開發(fā)人員提供可以為他們的產(chǎn)品提供可重用服務(wù)的基礎(chǔ)架構(gòu)。框架向開發(fā)人員提供一系列具有以下特征的骨架組件:1.已經(jīng)知道它們在其它程序上工作得很好;2.它們隨時可以在下一個項目中使用;3.它們可以被組織的其它團隊使用;對于框架是典型的構(gòu)建還是購買命題。如果你自己構(gòu)建它,在你完成時你就會理解它,但是在你被融入之前又將花費多長時間呢?如果要購買,你必須得克服學習曲線,同樣,在你可以用它進行工作之前又得花多長時間?這里沒有所謂正確答案,但許多觀察者都會同意,象Struts這樣的框架能提供比從頭開始開發(fā)更顯著的投資回報,特別是對于大型項目來說。其它類型的框架:框架的概念不僅用于應(yīng)用程序也可用于組件。在其它的資料里面,我們也介紹了一些可以和Struts一起使用的框架。這些包括Lucene搜索引擎,Scaffold工具包,Struts驗證器,以及Tiles標簽庫。與應(yīng)用框架一樣,這些工具也提供了一些半完成的版本,可以用在用戶的定制組件之中。某些框架被限制于專門的開發(fā)環(huán)境中。Struts以及本文中涉及的組件卻不是這樣。你可以在很多環(huán)境中來開發(fā)Struts:VisualAgeforJava,JBuilder,Eclipse,Emacs,甚至使用Textpad。對于你的工具,如果你可以用來開發(fā)Java,你就可以用它來開發(fā)Struts。使用的技術(shù):使用Struts的應(yīng)用開發(fā)使用了大量的其他基礎(chǔ)技術(shù)。這些技術(shù)并不是專門針對Struts,而是所有Javaweb應(yīng)用都可以使用的。開發(fā)者使用Struts之類的框架是為了隱藏在諸如HTTP,CGI,以及JSP之類技術(shù)后面的繁瑣的細節(jié)。作為一個Struts開發(fā)者,你并不需要知曉所有的相關(guān)知識,但是這些基本技術(shù)的工作原理可能有助于你針對棘手問題設(shè)計出創(chuàng)造性的方案。超文本傳輸協(xié)議(HTTP):當兩個國家之間進行調(diào)解時,外交官們總是遵循一定的正式協(xié)議。外交協(xié)議主要設(shè)計來避免誤解,以及防止談判破裂。同樣,當計算機間需要對話,它們也遵循一個正式的協(xié)議。這個協(xié)議定義數(shù)據(jù)是如何傳輸,以及它們到達后如何進行解碼。Web應(yīng)用程序就是使用HTTP協(xié)議在運行瀏覽器的計算機和運行的服務(wù)器的程序間傳輸數(shù)據(jù)。很多服務(wù)器應(yīng)用程序使用HTTP之外的其他協(xié)議。他們在計算機之間維護一個持久性的連接。應(yīng)用服務(wù)器可以清楚的知道是誰連接上來,而且何時中斷連接。因為它們知道每一個連接的狀態(tài),以及每一個使用它的人。這稱之為狀態(tài)協(xié)議。相反,HTTP是一個無狀態(tài)協(xié)議。HTTPServer可以接受來自于各種客戶的各種請求,并提供各種響應(yīng),即使是這個響應(yīng)僅僅是說No。沒有大量的協(xié)商和連接持久性,無狀態(tài)協(xié)議可以處理大量的請求。這也是Internet可以擴展到很多計算機的原因。HTTP成為通用標準的原因是其簡單性。HTTP請求看起來就像一個平常的文本文檔。這使應(yīng)用程序很容易創(chuàng)建HTTP請求。你甚至可以通過標準的程序如Telnet來手動傳遞一個HTTP請求。當HTTP響應(yīng)返回時,它也是一個開發(fā)者可以直接閱讀的平面文本。HTTP請求的第一行包含方法,其后是請求的來源地址和HTTP版本。HTTP請求頭跟在首行后面,可以沒有也可以有多個。HTTP頭向服務(wù)器提供額外的信息??梢园g覽器的種類和版本,可接受的文檔類型,瀏覽器的cookies等等。7種請求方法中,GET和POST是用得最多的。一旦服務(wù)器接收到請求,它就要產(chǎn)生一個HTTP響應(yīng)。響應(yīng)的第一行稱為狀態(tài)行,包含了HTTP協(xié)議的版本,數(shù)字型狀態(tài),以及狀態(tài)的簡短描述。狀態(tài)行后,服務(wù)器將返回一個HTTP響應(yīng)頭,類似于HTTP請求頭。如上所述,HTTP并不在請求間保持狀態(tài)信息。服務(wù)器接受請求,發(fā)出響應(yīng),并且繼續(xù)愉快地處理文本請求。因為簡單和效率,無狀態(tài)協(xié)議不適合于需要跟蹤用戶狀態(tài)的動態(tài)應(yīng)用。Cookies和URL重寫是兩個在請求間跟蹤用戶狀態(tài)的方式。cookie是一種特殊的信息包,存儲于用戶的計算機中。URL重寫是在頁面地址中存儲一個特殊的標記,Java服務(wù)器可以用它來跟蹤用戶。這兩種方法都不是無縫的,是用哪一個都意味著在開發(fā)時都要進行額外的工作。對其本身來說,標準的HTTPweb服務(wù)器并不傳輸動態(tài)內(nèi)容。它主要是使用請求來定位文件資源,并在響應(yīng)中返回此資源。通常這里的文件使用HypertextMarkupLanguage(HTML)[W3C,HTML]格式化,以使瀏覽器可以顯示它們。HTML頁面通常包含一些到其他頁面的超文本連接,也可以顯示其他一些內(nèi)容比如圖像和視頻等等。用戶點擊連接將產(chǎn)生另一個請求,就開始一個新的處理過程。標準web服務(wù)器處理靜態(tài)內(nèi)容處理得很好,但處理動態(tài)內(nèi)容時則需要額外的幫助手段了。定義靜態(tài)內(nèi)容直接來自于文本或數(shù)據(jù)文件,比如HTML或者JPEG文件。這些文件可以隨時改變,但通過瀏覽器請求時,卻不能自動改變。相反,動態(tài)內(nèi)容是臨時產(chǎn)生的,典型地,它是針對瀏覽器的個別請求的響應(yīng)。公共網(wǎng)關(guān)接口(CGI):第一個普遍用來產(chǎn)生動態(tài)內(nèi)容的標準是通用網(wǎng)關(guān)接口(CommonGatewayInterface(CGI))。CGI使用標準的操作系統(tǒng)特征,比如環(huán)境變量和標準輸入輸出,在Web服務(wù)器間以及和主機系統(tǒng)間創(chuàng)建橋接和網(wǎng)關(guān)。其他程序可以看到webserver傳遞過來的請求,并創(chuàng)建一個定制的響應(yīng)。當web服務(wù)器接收到一個對CGI程序的請求時,它便運行這個程序并向其提供它請求里面所包含的信息。CGI程序運行,并將輸出返回給Webserver,webserver則將輸出響應(yīng)給瀏覽器。CGI定義了一套關(guān)于什么信息將作為環(huán)境變量傳遞,以及它希望怎樣使用標準輸入和輸出的慣例。與HTTP一樣,CGI是靈活和易于實現(xiàn)的,并且已經(jīng)有大量現(xiàn)成的CGI程序。CGI的主要缺點是它必須為每個請求運行一個程序。這是一個相對昂貴的處理方法,對大容量站點來說,每分鐘有數(shù)千個請求,有可能使站點癱瘓。CGI程序的另一個缺點是平臺依賴性,一個平臺上開發(fā)的程序不一定在另一個平臺上能運行。Javaservlet:Sun公司的JavaServlet平臺直接解決了CGI程序的兩個主要缺點:首先,servlet比常規(guī)CGI程序提供更好的性能和資源利用。其次,一次編寫,隨處運行的JAVA特性意味著servlet在有JVM的操作系統(tǒng)間是輕便的可移動的。Servlet看起來好像是一個微小的webserver。它接受請求并產(chǎn)生響應(yīng)。但,和常規(guī)webserver不同,servletAPI是專門設(shè)計來幫助Java開發(fā)人員創(chuàng)建動態(tài)應(yīng)用的。Servlet本身是要編譯成字節(jié)碼的Java類,就像其他Java對象一樣。Servlet訪問HTTP特定服務(wù)的API,但它仍然是一個運行于程序之中的Java對象,并可以利用所有的Java資產(chǎn)。為了使常規(guī)webservers能訪問servlet,servlet被安插在一個容器之中。Servlet容器連接到Web服務(wù)器。每servlet都可以聲明它可以處理何種樣式的URL。當符合所注冊樣式的請求到達,webserver將請求傳遞給容器,容器則調(diào)用響應(yīng)的servlet。但和CGI程序不同,并不是針對每個請求都要創(chuàng)建一個新的servlet。一旦容器實例化了一個servlet,它就僅為每個新的請求創(chuàng)建一個新的線程。Java線程可比使用CGI程序的服務(wù)器處理開銷小多了。一旦servlet被創(chuàng)建,使用它處理額外的請求僅帶來很小的額外開銷。Servlet開發(fā)人員可以使用init()方法保持對昂貴資源的引用,比如到數(shù)據(jù)庫或者EJBHome接口的連接,以便它們可以在不同的請求之間進行共享。獲得這些資源要耗費數(shù)秒時間,這比大多數(shù)沖浪者愿意等的時間要長些。Servlet的另一個好處是,它是多線程的,servlet開發(fā)人員必須特別注意確保它們的servlet是線程安全的。學習servlet編程,我們推薦JavaServletsbyExample,作者AlanR.Williamson[Williamson]。JavaServerPages:雖然servlets對CGI程序來說前進了一大步,但它也不是萬能靈藥。為了產(chǎn)生響應(yīng),開發(fā)人員不得不使用大量的println語句來生成HTML。比如這樣的代碼:out.println("<P>OnelineofHTML.</P>");out.println("<P>AnotherlineofHTML.</P>");在產(chǎn)生HTTP

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論