版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
MySQL和JSP的Web那么JSPJSPSQLUMLJSPJSPJSPWebCGIJSPJavaJavaWebOut.println("<HTML>\n<HEAD>\n<TITLE>ThankyouforOut.println("<IMGSRC=\"thanks.jpg\"WIDTH=200HEIGHT=100HTMLservletJavaServer(在微软方面,成果是活动服务器页面。JSP1HTTP2、WEBJSP,JSPJSP是从.jsp种.class.jsp5、一种新创立的类实例被实例化,并发送_jspServiceSQLHTMLWebJavaHTML。servletWebDMZ安装方便(10Oracle。MySQLMySQLCREATETABLEUSER(USERIDINTEGER, CREATETABLEPURCHASEUSERIDFOREIGNKEYUSER(USERID),ITEMINTEGER,QUANTITYOraclePURCHASEID3PURCHASEUSERID3MySQL的人们做了一种美丽慷慨激昂的论点有关在各自的文档进行数据的完整性DBAship把Tomcat和MySQLiPlanetOracleWebSphereSQLServer。GNU(GPL)的人免费提供。(咨询公司陷入一种不可思议的空间,但至今没有人方便使用GPL而追逐它们。)原文出处《MySQLandJSPWebapplications》作者:JamesMySQLandJSPWebJSPdevelopersencounteruniqueproblemswhenbuildingwebapplicationsthatrequireintensedatabaseconnectivity.MySQLandJSPWebApplicationsaddressesthechallengesofbuildingdata-drivenapplicationsbasedontheJavaServerPagesdevelopmentmodel.MySQLandJSPWebApplicationsbeginswithanoverviewofthecoretechnologiesrequiredforJSPdatabasedevelopment--JavaServerPages,JDBC,andthedatabaseschema.ThebookthenoutlinesandpresentsanInternetcommerceapplicationthatdemonstratesconceptssuchasreceivingandprocessinguserinput,designingandimplementingbusinessrules,andbalancingtheuserloadontheserver.ThroughtheJDBC(JavaDataBaseConnector),thedevelopercancommunicatewithmostcommercialdatabases,suchasOracle.ThesolutionspresentedinMySQLandJSPWebApplicationscenterontheopensourcetoolsMySQLandTomcat,allowingthereaderanaffordablewaytotestapplicationsandexperimentwiththebook'sexamples.SoWhatIsJSPAllIfyoumeettherequirementsmentioned,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>Thankyoufor Thiskindofembeddinggetsveryoldveryfastwhenyouhavetocodealotofpages.Inaddition,havingtoescapeallofthequotationmarkscanleadtoalotofconfusingandhard-to-finderrorsifyouleaveoutabackslash.Eventually,astill-betterideaemerged.SupposethatyoucouldcombinethebestofstaticHTMLpagesandwiththeinteractivecapabilitiesofservlets.TheresultwasJavaServerPages(ontheMicrosoftside,theresultwasActiveServerPages).AsFigureI.1shows,JSPisacomplicatedbeast.Inthenextchapter,you'llwalkthroughthisflowindetail,butforthemoment,herearethemajorsteps:ArequestcomesinfromabrowserusingthenormalHTTPrequestTheWebserverhandsofftherequesttoJSP.JSPlooksatthefilenameandfindstheappropriateJSPfile.The.jspfileisconvertedintoa.javafile,containingJavacodethatwillcreateaclasswhosenameisderivedfromthe.jspfilename.JSPthencompilesthe.javafileusingjavactoproducea.classfile.Notethattwopreviousstepsareskippedifa.classfilealreadyexistsandisnewerthanthe.jspAninstanceofthenewlycreatedclassisinstantiatedandsentthe_jspServiceThenewinstancelookstoseeifthereisalreadyaninstanceofthestuff.Userobjectcalleduserexistinginthesessionobjectspaceforthecurrentlyconnecteduser.Ifnot,oneisinstantiated.Aspartofservicingstuff.jsp,theuserinstanceiscalledwiththegetUserName()IftheJSPprocessingrequiresaccesstoinformationinadatabase,itusesJDBCtomaketheconnectionandhandletheSQLrequests.Asyoucansee,atremendousamountofpowerisavailableintheJSPworld.DevelopersarefreetowriteWebpagesthatlookmostlylikeHTML,exceptwherecalloutstoJavaarerequired.But,atthesametime,theyarefreetodevelopfullyfleshed-outobject-orientedapplicationsusingallthefeaturesthatJavacanbringtobear.Theyalsogetallthebenefitsofservlets,includingsessionpersistence.WhyDoWeNeedWell,onereasonissothatLarryEllisonofOraclecanaffordtokeephimselfonProzacwhenhethinksaboutBillGates.Amoreseriousansweristhesamereasonthatdrovemantofirstpressastickagainstapieceofwetmud:becauseit'sgoodtowritethingsdown.Webserversaremarvelouscreatures,butthey'reabitlikeidiotsavants.AskthemtoserveaWebpageorrunapieceofJava,andtheyperformlikeachamp.Butstartaskingthemtorememberwhattheydidfiveminutesago,andtheydevelopamnesiafasterthanacharacterinasoapopera.Thefirstandmostimportantreasonthatyouusedatabasesisthatthere'salotinane-commercetransactionthatyouneedtorememberandtrack:•Auser'sname,address,creditcard,andotherinformationpreviouslyenteredonaregistrationpage•hattheusermighthaveputintoashoppingcartandleftfromaprevious•Whatitemsareinstock,alongwiththeirprice,description,andso•Ordersthatneedtobefulfilled,ordersthathavebeenshipped,anditemsthathavebeenbackordered.Now,youcouldstoreallthisinformationinaflatfileontheserver'sharddisk,butthereareotherimportantpropertiesthatyouwanttohaveforthisdata:•Youwanttobeabletobackoutatransactionifpartofit•YouwanttobeabletolocatethedatasomewheremoresecurethantheWebserver,whichcouldbeinaDMZoroutsidethefirewallaltogether.•Youwanttobeabletoaccessdatasuchasuserdataorproductsquickly,eveniftherearethousandsormillionsofthem.Whenyouaddtheseitemstotheshoppinglist,onlyarelationaldatabasewillreallydothejobeffectively.Manysitesdon'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.example,let'ssupposethatyouhadaschemethatlookedlikeCREATETABLEUSERUSERID CREATETABLEPURCHASEUSERIDFOREIGNKEYUSER(USERID),ITEMINTEGER,QUANTITYInadatabasesuchasOracle'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,addressesanumberoftheseincludingrow-levellockingandtransactionPuttingTomcatandMySQLCombiningTomcatandMySQLprovidesapowerful,reliable,andfreeplatformthatyoucanusetolearn,develop,anddeployJSPapplications.And,bestofall,thecodethatyoudevelopusingthisplatformwillrunnicelyusingiPlanetandOracleorWebSphereandSQLServer.Asalearningtoolthetwotogetherarealmost"referenceimplementations"oftheirrespectiveprotocols(JSPandSQL).Asaresult,youwon'tpickupanynastyvendor-proprietarybadhabitswhileyou'regettinguptospeed.Inaddition,youcanenjoytheknowledgethatyouaresupportingtheopen-sourcesoftwaremovement.Open-sourcesoftwareiscodethatismadefreelyavailableunderoneofseveralpubliclicenses,frequentlytheGNUGeneralPublicLicense(GPL).FACTSANDFICTIONABOUTTHETheGNUGeneralPublicLicenseisprobablyoneofthemostmisunderstooddocumentsinexistence,Thebasicsbreakdowntothis:IfyouplaceapieceofsoftwareundertheGPL,anyoneisfreetomakeacopyofitineithersourceorexecutableformandgiveittoanyoneelse.IfyoutakeapieceofsoftwareundertheGPLanduseitasapartofyourproduct
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 电力保安工作总结
- 2025年全球及中国交流造水机行业头部企业市场占有率及排名调研报告
- 2025年全球及中国IO-Link信号塔行业头部企业市场占有率及排名调研报告
- 2025年全球及中国吸收式工业消声器行业头部企业市场占有率及排名调研报告
- 2025-2030全球低聚半乳糖粉末行业调研及趋势分析报告
- 2025-2030全球双通道听力计行业调研及趋势分析报告
- 2025年全球及中国冰淇淋服务用品行业头部企业市场占有率及排名调研报告
- 2025-2030全球汽车水泵机械密封行业调研及趋势分析报告
- 2025-2030全球CT 扫描计量行业调研及趋势分析报告
- 2025合同模板建设工程施工合同(港口)范本
- (二模)遵义市2025届高三年级第二次适应性考试试卷 地理试卷(含答案)
- 二零二五隐名股东合作协议书及公司股权代持及回购协议
- IQC培训课件教学课件
- 2025年计算机二级WPS考试题目
- 高管绩效考核全案
- 2024年上海市中考英语试题和答案
- 教育部《中小学校园食品安全和膳食经费管理工作指引》知识培训
- 长沙医学院《无机化学》2021-2022学年第一学期期末试卷
- eras妇科肿瘤围手术期管理指南解读
- GB/T 750-2024水泥压蒸安定性试验方法
- 初一到初三英语单词表2182个带音标打印版
评论
0/150
提交评论