




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
中英文對照外文翻譯(文檔含英文原文和中文翻譯)MySQLandJSPWebapplicationsJSPdevelopersencounteruniqueproblemswhenbuildingwebapplicationsthatrequireintensedatabaseconnectivity.MySQLandJSPWebApplicationsaddressesthechallengesofbuildingdata-drivenapplicationsbasedontheJavaServerPagesdevelopmentmodel.MySQLandJSPWebApplicationsbeginswithanoverviewofthecoretechnologiesrequiredforJSPdatabasedevelopment--JavaServerPages,JDBC,andthedatabaseschema.ThebookthenoutlinesandpresentsanInternetcommerceapplicationthatdemonstratesconceptssuchasreceivingandprocessinguserinput,designingandimplementingbusinessrules,andbalancingtheuserloadontheserver.ThroughtheJDBC(JavaDataBaseConnector),thedevelopercancommunicatewithmostcommercialdatabases,suchasOracle.ThesolutionspresentedinMySQLandJSPWebApplicationscenterontheopensourcetoolsMySQLandTomcat,allowingthereaderanaffordablewaytotestapplicationsandexperimentwiththebook'sexamples.SoWhatIsJSPAllAbout?Ifyoumeettherequirementsmentioned,youshouldalreadyhaveaprettygoodideawhattheanswertothisquestionis.JSPisallaboutdoinghighlyobject-orientedWebsitesthatcanleverageallthebestpracticesofmodernsoftwareengineering.ThesepracticesincludethingssuchasSQLdatabasesandUML-baseddesign.Thisisn'ttosaythatJSPisacure-allandthatusingitwillautomaticallymakeyourWebsiteaparagonofengineeringart.It'sjustaspossibletodesignbadWebsitesinJSPaswithanyothertechnology.That'swhy,asyougothroughthetext,youwillseehowtoincorporatethebestpracticesandhowtoavoidthepitfallsofconveniencewhenprojectsgetstressful.JSPitselfisanevolutionarystepalongthepaththatstartedwiththefirststaticWebservers,movedthroughCGI-enabledservers,andfinallythefirstgenerationofscript-enabledservers.JSPislessaWebserverwithaJavacomponentthanitisaJavaenginethatunderstandstheWeb.JSPgrewoutofJavaservlets.ServletsallowthedevelopertohandletheincomingWebrequestsusingaJavaprogramthathasaccesstoallthenormalinformationthataCommonGatewayInterface(CGI)programwould.Inaddition,theservlethasaccesstosession-persistentobjects.TheseareJavaobjectsthatareassociatedwithaspecificusersessionandcanbeusedtostorestatebetweenrequests.Servletprogrammingwasamajorstepforwardinallowingdeveloperstowritewell-structuredmodularWebapplicationsusinganobject-orientedlanguage.Italsosolvedtheproblemofstatepersistence,allowingmoreinformationtoresideontheserverduringatransactionandlesstohavetopassbackandforthbetweentheuserandtheserver.Servletsstillsufferedfromonemajorproblem.BecausetheyeventuallyneedtospitoutHTML,theHTMLcodinghadtobeembeddedintheservletcode.Thisledtocodefragmentsliketheoneshownhere:Out.println("<HTML>\n<HEAD>\n<TITLE>ThankyouforRegistering</TITLE></HEAD>\n");Out.println("<IMGSRC=\"thanks.jpg\"WIDTH=200HEIGHT=100ALIGN=\"LEFT\”>");Thiskindofembeddinggetsveryoldveryfastwhenyouhavetocodealotofpages.Inaddition,havingtoescapeallofthequotationmarkscanleadtoalotofconfusingandhard-to-finderrorsifyouleaveoutabackslash.Eventually,astill-betterideaemerged.SupposethatyoucouldcombinethebestofstaticHTMLpagesandwiththeinteractivecapabilitiesofservlets.TheresultwasJavaServerPages(ontheMicrosoftside,theresultwasActiveServerPages).AsFigureI.1shows,JSPisacomplicatedbeast.Inthenextchapter,you'llwalkthroughthisflowindetail,butforthemoment,herearethemajorsteps:1.ArequestcomesinfromabrowserusingthenormalHTTPrequestformat.2.TheWebserverhandsofftherequesttoJSP.JSPlooksatthefilenameandfindstheappropriateJSPfile.3.The.jspfileisconvertedintoa.javafile,containingJavacodethatwillcreateaclasswhosenameisderivedfromthe.jspfilename.4.JSPthencompilesthe.javafileusingjavactoproducea.classfile.Notethatthetwopreviousstepsareskippedifa.classfilealreadyexistsandisnewerthanthe.jspfile.5.Aninstanceofthenewlycreatedclassisinstantiatedandsentthe_jspServicemessage.6.Thenewinstancelookstoseeifthereisalreadyaninstanceofthestuff.Userobjectcalleduserexistinginthesessionobjectspaceforthecurrentlyconnecteduser.Ifnot,oneisinstantiated.7.Aspartofservicingstuff.jsp,theuserinstanceiscalledwiththegetUserName()method.8.IftheJSPprocessingrequiresaccesstoinformationinadatabase,itusesJDBCtomaketheconnectionandhandletheSQLrequests.Asyoucansee,atremendousamountofpowerisavailableintheJSPworld.DevelopersarefreetowriteWebpagesthatlookmostlylikeHTML,exceptwherecalloutstoJavaarerequired.But,atthesametime,theyarefreetodevelopfullyfleshed-outobject-orientedapplicationsusingallthefeaturesthatJavacanbringtobear.Theyalsogetallthebenefitsofservlets,includingsessionpersistence.WhyDoWeNeedDatabases?Well,onereasonissothatLarryEllisonofOraclecanaffordtokeephimselfonProzacwhenhethinksaboutBillGates.Amoreseriousansweristhesamereasonthatdrovemantofirstpressastickagainstapieceofwetmud:becauseit'sgoodtowritethingsdown.Webserversaremarvelouscreatures,butthey'reabitlikeidiotsavants.AskthemtoserveaWebpageorrunapieceofJava,andtheyperformlikeachamp.Butstartaskingthemtorememberwhattheydidfiveminutesago,andtheydevelopamnesiafasterthanacharacterinasoapopera.Thefirstandmostimportantreasonthatyouusedatabasesisthatthere'salotinane-commercetransactionthatyouneedtorememberandtrack:?Auser'sname,address,creditcard,andotherinformationpreviouslyenteredonaregistrationpage?hattheusermighthaveputintoashoppingcartandleftfromaprevioustransaction?Whatitemsareinstock,alongwiththeirprice,description,andsoon?Ordersthatneedtobefulfilled,ordersthathavebeenshipped,anditemsthathavebeenbackordered.Now,youcouldstoreallthisinformationinaflatfileontheserver'sharddisk,butthereareotherimportantpropertiesthatyouwanttohaveforthisdata:?Youwanttobeabletobackoutatransactionifpartofitfails.?YouwanttobeabletolocatethedatasomewheremoresecurethantheWebserver,whichcouldbeinaDMZoroutsidethefirewallaltogether.?Youwanttobeabletoaccessdatasuchasuserdataorproductsquickly,eveniftherearethousandsormillionsofthem.Whenyouaddtheseitemstotheshoppinglist,onlyarelationaldatabasewillreallydothejobeffectively.MySQLManysitesdon'tneedthebattleshipstrength(andpricetag)ofOracle.MySQLisanopen-sourceSQLdatabaseavailableforanyonetouse,withmany(althoughnotall)ofthefeaturesofitsbigbrothers,suchasOracle.MySQLisavailableforjustaboutanycomputerthathasdecentpower—itisfairlylightweightontheprocessorandeasytoinstall(10minutes,asopposedtomultiplehoursforOracle).So,perhapsyouarewondering,what'sthecatch?WhatareyounotgettinginMySQLthatmakespeopleturntoOracle?Well,MySQLisaneatlittlepackage,butitismissingsomethingsthatwouldbenicetohaveinaperfectworld.AmajorfeaturethatMySQLdoesnotofferisdatabaseconsistencychecking.Youcanuseforeignkeytagsinyourschema,butMySQLcheerfullyignoresthem.AlotofDBAsIknowwouldconsiderthisaverybadthing.Aforeignkeyconstraintpreventsyoufromcreatinginconsistentdata.Forexample,let'ssupposethatyouhadaschemethatlookedlikethis:CREATETABLEUSER(USERIDINTEGER,FIRST_NAMEVARCHAR(80),LAST_NAMEVARCHAR(80));CREATETABLEPURCHASE(USERIDFOREIGNKEYUSER(USERID),ITEMINTEGER,QUANTITYINTEGER);InadatabasesuchasOracle's,ifyoucreatedanentryinthePURCHASEtablewithauserIDof3,therewouldhavetoalreadybeauserIDof3intheUSERtableoranerrorwouldoccur.Similarly,youcouldn'tdeleteuser3fromUSERifitwasreferencedinPURCHASE.TheMySQLfolksmakeaprettyimpassionedargumentintheirdocumentationthatdependingonforeignkeysfordataintegrityisabadideaanyway,butconvincingyourDBAofthisphilosophyislikelytodegradeintoareligiousdebate.Inaddition,someotherfeaturesaremissing,suchassubselectsandselectinto.Butprobablytheothermajorpiecethatyouwillmissistherollback/commitfunctionality.MySQLdoesimplementrollbackandcommitforcertaintypesoftables,butnotallofthem.Again,theMySQLfolksoffertheirownspinonwhythisisokay,butbeingabletorollbacktransactionsis(inmyopinion)importantenoughtomakesurethatyouhaveitavailable.Rollbackallowsyoutosetasavepointonthedatabasebeforestartingtodoaseriesoftransactionswithit,andbeabletoeitherrollbacktotheoriginalstateorcommitthechangesattheend.Forexample,whenrecordingapurchase,youneedtorecordadebitagainsttheuser'saccountandenterarecordintotheshippingtablesothatyou'llknowlatertoshiptheitem.Let'ssaythatthesecondpartfails.Youwouldn'twanttochargetheuserbutnotshiptheitem.Thus,you'dwanttorollbacktothestatebeforethetransactionbegan.So,MySQLisn'tafull-blownproductiondatabase—atleast,notyet.It'sstillgoodenoughforprobably90%ofthee-commercesitesintheworld,however.Andversion4.0,whichisinalphaasofthiswriting,addressesanumberoftheseconcerns,includingrow-levellockingandtransactioncontrol.PuttingTomcatandMySQLTogetherCombiningTomcatandMySQLprovidesapowerful,reliable,andfreeplatformthatyoucanusetolearn,develop,anddeployJSPapplications.And,bestofall,thecodethatyoudevelopusingthisplatformwillrunnicelyusingiPlanetandOracleorWebSphereandSQLServer.Asalearningtoolthetwotogetherarealmost"referenceimplementations"oftheirrespectiveprotocols(JSPandSQL).Asaresult,youwon'tpickupanynastyvendor-proprietarybadhabitswhileyou'regettinguptospeed.Inaddition,youcanenjoytheknowledgethatyouaresupportingtheopen-sourcesoftwaremovement.Open-sourcesoftwareiscodethatismadefreelyavailableunderoneofseveralpubliclicenses,frequentlytheGNUGeneralPublicLicense(GPL).Whyisitgoodtosupportthismovement?Therearetwosidestothisanswer:onetechnicalandonepolitical.Technically,it'sagoodthingbecauseopen-sourcesoftwaretendstoencouragethedevelopmentofopenstandardssuchasJSPandJDBC,allowingyoutochooseyourtoolsfromamongalargergroupratherthanbeinglockedintoonevendor'sproprietarysolution.It'sapositivethingpoliticallybecauseitkeepsthelargecompanieshonest.WebLogicandiPlanethavetostaycompetitiveandresponsivebecausetheyknowthatthere'safreesolutionoutthereiftheyaren't.Andwhenyouuseopen-sourcesoftware,youaresendingamessagethatyouroverridingconcernsarefeaturesandreliability,nothavingalargecompanytosueifsomethinggoeswrong.MySQL和JSP的Web應用程序JSP開發人員構建Web應用程序時遇到需要強大的數據庫連接的特殊問題。MySQL和JSP的Web應用程序解決了構建數據驅動的應用程序JavaServer頁面上的發展模式為基礎的挑戰。MySQL和JSP的Web應用程序開始一個對JSP數據庫開發-JavaServer頁面,JDBC和數據庫模式所需的核心技術概述。該書然后概述并提出了互聯網商業應用演示,如接收和處理用戶輸入,設計和實施業務規則,并平衡服務器上的用戶負載的概念。通過JDBC(Java數據庫連接),開發人員能夠與大多數商業數據庫如Oracle進行溝通。在MySQL和JSP的Web應用中心提交了一份關于開源工具MySQL和Tomcat的解決方案,使讀者一個經濟實惠的方式來測試書中的例子的應用程序和試驗。那么JSP是怎么一回事呢?如果您符合上述要求的,你對這個問題的答案應該已經有一個相當不錯的理解。JSP是所有關于做高度面向對象的網站,可以利用所有的現代軟件工程最佳實踐。這些做法包括諸如SQL數據庫和基于UML設計的東西。這并不是說JSP是萬能的而且使用它會自動將您的網站上的工程藝術的典范。這只是盡可能地用其他任何技術用JSP設計不良網站。這就是為什么,當你詳細檢查文本的時候,你會看到如何合并最佳方法以及項目得到的壓力時候如何避免方便的陷阱。JSP它本身就是從第一個靜態Web服務器開始的一個沿路徑循序漸進的步驟,通過CGI移動功能的服務器,最后腳本功能的服務器的第一代。JSP是一個比Java引擎能夠熟悉網頁的的少了一個Java組件的Web服務器。JSP是由Javaservlet發展演變而來的。servlet允許開發人員處理傳入使用Java程序能夠訪問的所有正常的信息,一個共同的網關接口(CGI)程序將Web請求。此外,該servlet可以訪問會話持久對象。這是Java的都與一個特定的用戶會話,可用于存儲請求之間的狀態對象。Servlet編程是一個允許開發人員編寫結構良好的模塊化的Web應用程序使用面向對象語言的重要一步。它還解決了狀態持久性的問題,用戶和應用程序執行的一個動作或一系列動作期間讓更多的信息駐留在服務器上而且較少的反復在用戶和服務器之間傳遞。Servlet還遭受一大問題。因為他們最終需要輸出HTML中,HTML編碼必須被嵌入在servlet代碼中。導致如下所示的一段代碼片段:Out.println("<HTML>\n<HEAD>\n<TITLE>ThankyouforRegistering</TITLE></HEAD>\n");Out.println("<IMGSRC=\"thanks.jpg\"WIDTH=200HEIGHT=100ALIGN=\"LEFT\”>");當你編碼很多網頁時,這種嵌入式是非常古老非常快的。此外,必須避免所有引號會導致的很多混亂和如果你遺漏了一個反斜杠帶來難以發現的錯誤。最終,一個較好的方法出現。假設你能結合最好的靜態HTML頁面和servlet的交互能力。其結果是JavaServer頁面(在微軟方面,結果是活動服務器頁面)。JSP是非常復雜強大的。在接下來的章節中,你會通過這個細節流程,但就目前而言,這里是主要的步驟:1、接到請求時從使用普通的HTTP請求格式的瀏覽器。2、WEB服務器切換到JSP的請求,JSP著眼于找到合適的JSP文件。3、.jsp文件轉換成.Java文件,包含Java代碼,將創建一個類,它的名稱是從.jsp的文件名而得。4、JSP然后用javac編譯.java文件產生一個.class文件。注意如果一個.class文件已經存在而且比.jsp文件新則可以跳過先前的兩步。5、一個新創建的類實例被實例化,并發送_jspService消息。6、新的實例看看是否已經有一個被稱為user的stuff.User對象實例在當前連接的用戶會話對象的空間存在。如果沒有,一個實例被實例化。7、作為服務stuff.jsp的一部分,user實例將被GetUserName()方法調用。8、如果JSP處理需要訪問數據庫中的信息,它將使用JDBC來進行連接和處理SQL請求。正如你可以看到,巨大的能量是在現有的JSP世界里。開發者可以自由編寫大多數看起來像HTML的Web頁面,除非到Java標注是要求最喜歡看的HTML。但是,在同一時間,他們可以自由地充分發展充實面向對象的應用程序使用Java會帶來負擔的所有功能。他們也得到servlet的所有優點,包括會話持久性。為什么我們需要的數據庫?好,一個原因就是為了讓拉里埃里森想到比爾蓋茨的時候,他的Oracle有能力保持自己百憂解。更嚴重的回答是相同的原因也就是駕駛人先按下針對一塊濕粘泥:因為把事情記下來是好的。Web服務器是了不起的創造,但他們是一個有點像白癡專家。請他們為一個網頁或運行Java的一段,他們表演的像一個冠軍。但開始要求他們記住他們五分鐘前做了什么,和他們顯露的比一個肥皂劇里的人物失憶還快。第一個也是最重要的原因是你使用的數據庫是有大量的數據在電子商務交易里,你必須記住并跟蹤:?一個用戶的姓名,地址,信用卡和其他信息以前進入了一個注冊頁面?帽子的用戶可能把以前留下交易放進購物車?哪些物品有存貨,以及它們的價格,描述等等?訂單需要履行,訂單已發貨,并已待補物品。現在,你可以存儲所有這些信息在服務器上的硬盤平面文件中,但也有你想保存的數據的其他重要屬性:?如果交易部分失敗,您希望能夠收回交易。?您希望能夠找到Web服務器安全的地方定位數據,這可能是完全在DMZ或外部的防火墻。?您希望能夠如用戶數據或產品快速訪問數據,即使有數千或上百萬數據。當你添加這些項目的購物清單,只有一個關系數據庫才會真正的影響工作效率。MySQL許多網站不需要Oracle的歷史優勢(和價格標簽)。MySQL是一個開源SQL數據庫可供任何人使用,擁有許多(盡管不是全部)的先前數據庫的功能,如Oracle。MySQL是可用于幾乎所有的電腦上有相當好的能力是相當輕量級的處理器,安裝方便(10分鐘,而不像Oracle需要多個小時)。所以,也許你想知道,有什么收獲?沒有得到什么,你在MySQL中,使人們把目光轉向到O
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 單位資產劃轉協議書
- 2025年03月浙江臺州市黃巖區事業單位公開招聘工作人員100人筆試歷年典型考題(歷年真題考點)解題思路附帶答案詳解
- 2025年03月國家衛生健康委統計信息中心公開招聘人才派遣1人筆試歷年典型考題(歷年真題考點)解題思路附帶答案詳解
- 三維多向整體編織物項目安全風險評價報告
- 中國礦業大學《現代漢語A》2023-2024學年第二學期期末試卷
- 批發服務項目安全風險評價報告
- 鄭州美術學院《運動技能學習與控制》2023-2024學年第一學期期末試卷
- 湖南大學《英語聽力1》2023-2024學年第一學期期末試卷
- 江西農業大學《廣告創意與策劃》2023-2024學年第二學期期末試卷
- 上海興偉學院《TracePro光路設計》2023-2024學年第二學期期末試卷
- 淺談基層禁毒工作存在的問題及對策
- GB/T 19879-2023建筑結構用鋼板
- 駕駛員滿意度調查表
- 2學術性評價意見
- 差積、累積曲線模板
- 汽車二級維護進廠及過程檢驗單參考模板范本
- 安徽省天然氣開發股份有限公司天然氣蕪銅支線戴店幼兒園段遷改工程項目環境影響報告書
- 敘事護理學智慧樹知到答案章節測試2023年中國人民解放軍海軍軍醫大學
- 汽車涂裝技術(陜西國防工業職業技術學院)智慧樹知到答案章節測試2023年
- 受迫振動與共振實驗課件
- 2023年中考中考語文專題復習:關聯詞 專項練習題(含答案解析)
評論
0/150
提交評論