外文翻译 - JSP的技术方法_第1页
外文翻译 - JSP的技术方法_第2页
外文翻译 - JSP的技术方法_第3页
外文翻译 - JSP的技术方法_第4页
外文翻译 - JSP的技术方法_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

0外文原文ThinkinginJavaWilliamGibsonJSPcomputingtechniqueTocarryonthedynamicwebsiteconvenientlyfastthedevelopment,JSPhasmadetheimprovementinthefollowingseveralaspects,causesittobecomebuildsthecrossplatformfastthedynamicwebsitefirstchoiceplan.1.CarriesontheseparationthecontentproductionandthedemonstrationWiththeJSPtechnology,theWebpagedevelopmentpersonnelmayuseHTMLortheXMLmarkingdesignandtheformattedfinalpage,andusestheJSPmarkingorthetootsyproducesonpagesdynamiccontent(contentisoriginallyactsaccordingtorequestchange,forexamplerequestaccountinformationoraspecificbottleofliquorpriceandsoon).ProductioncontentslogicissealedinmarksandintheJavaBeansmodule,andtiesupinthescript,allscriptsinserverendmovement.BecausecorelogicissealedinmarksandinJavaBeans,thereforetheWebadministrativepersonnelsandthepagedesigner,caneditandusetheJSPpage,heserverend,theJSPengineexplainedthattheJSPmarkingandthescript,producethecontentwhichrequested(e.g.,throughvisitstheJavaBeansmodule,usesJDBCtechnologyvisitdatabaseorincludedfile),and(orXML)pagesformtransmitstheresultbyHTMLthebrowser.Thisbotharehelpfulintheauthorprotectsowncode,andcanguaranteeanybasedontheHTMLWebbrowserscompleteusability.2.MayentrustwithheavyresponsibilitythemoduleTheoverwhelmingmajorityJSPpagereliesonmayentrustwithheavyresponsibility,thecrossplatformmodule(JavaBeansorEnterprisetheJavaBeansmodule)carriesoutcomplexprocessingwhichtheapplicationprocedurerequests.Thedevelopmentpersonnelcanshareandexchangetheexecutionordinaryoperationthemodule,orcausesthesemodulesusesformoreusersandthecustomerassociation.Hasacceleratedtheoverall1developmentprocessbasedonmodulesmethod,andcauseseachkindoforganizationobtainsbalancedintheirexistingskillandintheoptimizedresultdevelopmentendeavor.3.UsesmarkingTheWebpagedevelopmentpersonnelwillnotbethefamiliarscriptlanguageprogrammers.TheJSPtechnologyhassealedmanyfunctions,thesefunctionsareeasytouse,markingtocarryonthedynamiccontentproductionwithJSPintherelatedXMLtoneed.ThestandardJSPmarkingcanvisitandtheinstantiationJavaBeansmodule,theestablishmentortheretrievalmoduleattribute,downloadsApplet,aswellastheexecutiondifficultywithcodesandthetime-consumingfunctionwithothermethods.4.AdaptstheplatformNearlyallplatformssupportJava,JSP+JavaBeanstobepossibletopassunimpedednearlyunderallplatforms.Transplantsfromaplatformtootherplatform,JSPandJavaBeansdoesnotevenneedtotranslate,becausetheJavabytecodeisstandardhasnothingtodowiththeplatform.5.DatabaseconnectionInJavaconnectsthedatabasethetechnologyistheJDBC,JavaprocedureisconnectedthroughtheJDBCdriverandthedatabase,operationsandsoonexecutioninquiry,extractiondata.SunCorporationhasalsodevelopedJDBC-ODBCbridge,usesthistechnicalJavaproceduretobepossibletovisithastheODBCdriverdatabase,atpresentthemajoritydatabasesystemshavetheODBCdriver,thereforetheJavaprocedurecanvisitsuchasOracle,Sybase,MSSQLServeranddatabasesandsoonMSAccess.inaddition,throughthedevelopmentmarkingstorehouse,theJSPtechnologymayfurtherexpand.Thethirdpartydevelopmentpersonnelandotherpersonnelmayfoundtheirmarkingstorehouseforthecommonlyusedfunction.ThisenablestheWebpagedevelopmentpersonneltobeabletousethefamiliartoolandtobesimilartomarkingsamecarriesoutthespecificfunctioncomponenttocarryonthework.TheJSPtechnologyveryeasyconformitytomanykindsofapplicationarchitecture,tousetheextanttoolandtheskill,andcanexpandtothesupportenterprisedistributional2application.AsusestheJavatechnologyfamilyapart,aswellasJava2(enterpriseversionarchitecture)aconstituent,theJSPtechnologycansupporthighlycomplexbasedontheWebapplication.BecausetheJSPpagesbuilt-inscriptlanguageisbasedonJava,moreoverallJSPpageistranslatedintoJavaServlets,thereforetheJSPpagehasJavatechnologyalladvantage,includingvigorousandhealthystoremanagementandsecurity.AsaJavaplatformspart,JSPhastheJavaprogramminglanguage“acompilation,eachplacemovement”characteristic.JSPapplicationmodelUsingtheJSPtechnology,thedynamicinformationdisplaysbytheJSPpage,theJSPpagebyinstalls,intheWebserverorusesJSPontheapplicationserversJSPengineexecution.TheJSPengineacceptstheclientsidetotheJSPpagesrequest,andproducestheJSPpagetotaketotheclientsideresponse.TheJSPpageisusuallytranslatedintoJavaServlets,thisisastandardJavaexpansion.ThepagedevelopmentpersonnelcanvisitthecompleteJavaapplicationenvironment,usestheJavatechnologytheextensionandtheprobability.WhentheJSPpagefirsttimeistransferred,ifithasnotexisted,willbetranslatedintoJavatheServletskind,andwillsaveinserversmemory.Thiscausesinfollowingtothispagestransfer,theservercouldhavetheveryquickresponse(thistoavoidCGI-BINiseachHTTPrequestproducesanewadvancementquestion).TheJSPpagemaycontaininmanykindsofdifferentapplicationarchitectureorthemodel,mayuseintheunifiedbodywhichbythedifferentagreement,themoduleandtheformiscomposed.BasedontheJSPdynamicinformationissuetechnologyisoneopen,theexpandableestablishmentdynamicWebpagesstandard.Nomatterusesanyfoundationtool,thedevelopmentpersonnelmayusetheWebapplicationwhichtheJSPpagefoundsmaytransplant,movesonthedifferentWebapplicationserver.JSPgrammarTheJSPdocument(expansionnamed.jsp)maycontaintheinstruction(oriscalled3instructionsentence),theClass-widevariableandthemethod,thestraightinsertionJavacode(scriptlet),visitsJavaBean,thevariabledataHTMLmodel,thevariabledataJavaexpressioncombination.1.JSPinstructionThesoftwarepackagewhichusestheJSPinstruction()toassigntousethescriptlanguagewhich,Servletrealizetheconnectionwhich,Servlettoexpandthekindwhich,Servletinduct.TheJSPinstructionsgeneralsyntaxformis:.Andeffectiveinstructionnamed:(1)language:Inthedocumentusesscriptlanguage.ThistimeregardingtheJavaprogramminglanguage,onlyjavaistheeffectivevalueandthedefaultvalue.Thisinstructionfunctionintheentiredocument.Whenusesthisinstructionmanytimes,onlythenthefirstuseiseffective.Thedemonstrationisasfollows:.(2)Method:Methodnamewhich(scriptlet)producesbytheinsertingJavacode.Theproductioncodewillbecomeassignsthesidenameinreligionthemainbody.Thedefaultmethodisservice.Whenusesthisinstructionmanytimes,onlythenthefirstuseiseffective.Thedemonstrationisasfollows:.(3)Import:ServletinductsJavathelanguagesoftwarepackagenameorthekindaretables,thistabulationisseparateswiththecomma.IntheJSPdocument,mayassignthisinstructiontoinductthedifferentsoftwarepackagemanytimes.Thedemonstrationisasfollows:.(4)content_type:ProductionresponseMIMEtype.Thedefaultvalueistext/html.Whenusesthisinstructionmanytimes,onlythenthefirstuseiseffective.Thisinstructionavailableassignsincarriesonthecodetothepagethecharacterrepertoire.Thedemonstrationisasfollows:.(5)mplements:UsesinJavalanguageconnectiontabulationwhichproducesServlettorealize,thistabulationisseparateswiththecomma.MayusethisordermanytimesinaJSPdocument,realizesthedifferentconnection.Thedemonstrationisasfollows:.(6)extends:ServletexpandsJavalanguageclassname.Thiskindmustbeeffective,and4cannotbeaServletkind.ThisinstructionfunctioninentireJSPdocument.Whenusesthisinstructionmanytimes,onlythenthefirstuseiseffective.Thedemonstrationisasfollows:.2.class-widevariableandmethodTheuseandthemarkshowServletthekindofclass-widevariableandtheclass-widemethod.Thegeneralsyntaxisasfollows:。/class-widevariableandmethodcodeAttributerunat=serverisessential,itindicatedthatthismarkusesinserverendprocessing.Assignstheclass-widevariableandthemethoddemonstrationisasfollows:/class-widevariableiniti=0;Stringfoo=Hello;/class-widemethodprivatevoidfoo()/thismethodcode3.VisitsJavaBeanJSPthesupportenablesyoutoJavaBeanrepeatedlytousethemodulethroughtheWebstand.JavaBeanmaybeakindofdocumentorserialBean,mayalsobytheServletdynamicproduction.PleaseusemarksfoundsaBeanexample,causesfromJSPdocumentanyplacetobepossibletocarryonvisittothisexample.Themarkgrammaris:5Inwhichattributeandthemeaningareasfollows:(1)name:Usesinthecorrespondingscope(assignsbythescopeattribute)tosearchBeanthename.Forexample,thispossiblyisusesinsavingBeantheconversation(session)theessentialvalue.Thisvalueisdividedthebigsmallletter.(2)varname:UsesinanyplacequotingBeanintheJSPdocumentthename.Thisattributeismayelect.Thedefaultvalueisthenameattributevalue.Thisvalueisdividedthebigsmallletter.(3)type:Beankindoffilename.ThisnameusesinbythecodeshowingtheBeanexample.ThedefaultvalueistheObjecttype.Thisvalueisdividedthebigsmallletter.(4)Introspect:Whenthisvalueisatruetime,theJSPprocessorinspectionallrequestattribute,andwilltransferandtherequestattributematchsetattributemethodcollection(thisattributewillbetransmitsinBeanInfo).Thisattributedefaultvalueis.(5)BeanName:Bean.classfilename,theBeansoftwarepackagenameorcontainsBeantheserialdocument(the.serdocument)filename.(thisnameisforBeanexampleprocedure).WhenonlyBeannotinassignsinscope,whenfoundstheattributeestablishesis,onlythenusesthisattribute.Thisvalueisdividedthebigsmallletter.ThedocumentwaymustinapplyinserversJavakindofwaytoassign,onlyifdocumentinapplicationserver_rootunderservletstableofcontents.(6)Create:Whenthisvalueisatruetime,ifprocessorinassignsinthescopehasnotfoundBean,thenJSPwillfoundaBeanexample.Thedefaultvalueisreally.(7)Scope:Beanlifespan.Thisattributeismayelect,itsdefaultvalueisrequest.Theeffectivevalueis:request-establishesbyServletBeantherequestthecontext,thisServletusesAPIwhichinJSPAPIdescribestotransfertheJSPdocument.IfBeanisnotrequestedthatthecontextapart,willfoundthisBean,anditsmemoryinrequestcontext,onlyiffoundstheattributetoestablishasotherwise.6session-,ifinthecurrentdialoghasBean,thenBeanhasbeenentrustedwithheavyresponsibility.IfdoesnothaveBean,andfoundstheattributetoestablishforis,thenitwasfoundedandsavesasaconversationpart.userprofile-bytheServletrequestobjectretrieval,themodellingbecomesthetypewhichassigns,andcarriesontheintrospectiontheuserbrieftabledocument.(inIBMinWebShereapplicationserver,defaulttypeiscom.ibm.servlet.personalization.userprofile.UserProfile).(8)param:Attributeandvaluepairtabulation.TheattributeisusestheintrospectionautomaticsetupinBean.OnlywheninstantiationBean,onlythencarriesontheestablishmenttotheattribute.EstablishestheBeanattributebesidestheuseattribute,butmayalsouseotherthreemethods:First,intherequestcontainsBeantheWebpage(theJSPdocument)whenURL,assignstheinquiryparameter.Mustself-alerttheattributetoestablish“is”.Itsdemonstrationisasfollows:/signon.jsp?name=jones&password=d13x,theBeanattributegreatsoldierestablishmentisjones.Thesecondmethod,assignstheattributetomarkbyHTMLthesubmissiontheparameter.Mustestablishthemothodattributepost.EstablishestheactionattributetransfersBeanJSPdocumentURL.Mustestablishtheintrospectattribute“is”.Itsdemonstrationisasfollows:ThethirdmethodisusestheJSPgrammartoestablishtheBeanattribute.Afterhavingassignedthemark,mayvisitBeanfromJSPdocumentanyplace.HerehasthreekindstovisittheBeanattributemethod:UsesJSPscriptlet,tousetheJSPexpression,theusemark(issimilartovariabledatainHTMLtemplategrammarexplained).PleaserefertotheJSPdemonstration(theDisplayData.jspdocument)togainthreetovisittheBean7methodeachmethoddemonstration.JSPprovidedalladvantagesoftheJavaServlet,and,whencombinewithaJavaBeanstogether,providingakindofmakecontentsandmanifestationthatsimplewaythatlogicseparate.4.straightinsertionJavacode(scriptlet)MayinsertanyeffectiveJavalanguagecodedirectlyintheJSPdocumentmark.Suchinsertingcodeiscalledscriptlet.Ifhasnotassignedthemethodinstruction,thenproducesthecodewillbecometheservicemethodthemainbody.UsesinServletscriptletbeingpossibletouseapre-definitionthevariablecollection,thisvariablecollectionconformstobasicServlet,theoutputandtheinputclass:(1)request:Servletrequestclass(2)responseswhichdefinesbyjavax.servlet.http.HttpServletRequest:Servletresponseclass(3)outwhichdefinesbyjavax.servlet.http.HttpServletRequest:Outputtransducerclass(4)inwhichdefinesbyjava.io.PrintWriter:Inputreaderclasswhichdefinesbyjava.io.BufferedReaderItsdemonstrationisasfollows5.VariabledataHTMLtemplategrammarWhenthepagereturnstoforthebrowser,enablesyouusingtheserverHTMLtemplategrammartoplacethevariablefieldontheHTMLpage,andcausesServletandJavaBeanmaydynamicreplacethevariableusingthedatabasevalue.ThisfunctionisJSPIBMexpands,itcausesthequotationvariabledatabecomesveryeasy.ThisgrammarcanonlyuseintheJSPdocument.TheHTMLtemplategrammarincludes:BasicHTMLtemplategrammar;8SubstitutestheHTMLtemplategrammar;Mark.ThesemarksaredesignedthemarkwhichthroughtheHTMLcompilationtoolthetransmissionoperatesalternately.Eachmarkhadacorrespondingendmarker.Eachmarkisdividedthebigsmallletter,theirsomeattributesarealsodividedthebigsmallletter.IBMWebSphereStudiocausestodeveloptheJSPdocumenttocontaintheHTMLtemplategrammarbecomeseasier.9中文翻译JSP的技术方法为了快速方便地进行动态网站的开发,JSP在以下几个方面做了改进,使其成为快速建立跨平台的动态网站的首选方案。1.将内容的生成和显示进行分离用JSP技术,Web页面开发人员可以使用HTML或者XML标识来设计和格式化最终页面,并使用JSP标识或者小脚本来生成页面上的动态内容(内容是根据请求变化的,例如请求账户信息或者特定的一瓶酒的价格等)。生成内容的逻辑被封装在标识和JavaBeans组件中,并且捆绑在脚本中,所有的脚本在服务器端运行。由于核心逻辑被封装在标识和JavaBeans中,所以Web管理人员和页面设计者,能够编辑和使用JSP页面,而不影响内容的生成。在服务器端,JSP引擎解释JSP标识和脚本,生成所请求的内容(例如,通过访问JavaBeans组件,使用JDBC技术访问数据库或者包含文件),并且将结果以HTML(或者XML)页面的形式发送回浏览器。这既有助于作者保护自己的代码,又能保证任何基于HTML的Web浏览器的完全可用性。2.可重用组件绝大多数JSP页面依赖于可重用的、跨平台的组件(JavaBeans或者EnterpriseJavaBeans组件)来执行应用程序所要求的复杂的处理。开发人员能够共享和交换执行普通操作的组件,或者使得这些组件为更多的使用者和客户团体所使用。基于组件的方法加速了总体开发过程,并且使得各种组织在他们现有的技能和优化结果的开发努力中得到平衡。3.采用标识Web页面开发人员不会都是熟悉脚本语言的编程人员。JSP技术封装了许多功能,这些功能是在易用的、与JSP相关的XML标识中进行动态内容生成所需要的。标准的JSP标识能够访问和实例化JavaBeans组件,设置或者检索组件属性,下载Applet,以及执行用其他方法更难于编码和耗时的功能。4.适应平台几乎所有平台都支持Java,JSPJavaBeans几乎可以在所有平台下通行无阻。从一个平台移植到另外一个平台,JSP和JavaBeans甚至不用重新编译,因为Java字节码都是标准的与平台无关的。5.数据库连接Java中连接数据库的技术是JDBC,Java程序通过JDBC驱动程序与数据库相连,执行查询、提取数据等操作。Sun公司还开发了JDBCODBCbridge,利用此技术Java程序可以访问带有ODBC驱动程序的数据库,目前大多数数据库系统都带有ODBC驱动程序,所以Java程序能访问诸如Oracle、Sybase、MSSQLServer和MSAccess等数据库。此外,通过开发标识库,JSP技术可以进一步扩展。第三方开发人员和其他人员可以为常用功能创建自己的标识库。这使得Web页面开发人员能够使用熟悉的工具和如同标识一样的执行特定功能的构件来进行工作。JSP技术很容易整合到多种应用体系结构中,以利用现存的工具和技巧,并且能10扩展到支持企业级的分布式应用中。作为采用Java技术家族的一部分,以及Java2(企业版体系结构)的一个组成部分,JSP技术能够支持高度复杂的基于Web的应用。由于JSP页面的内置脚本语言是基于Java的,而且所有的JSP页面都被编译成为JavaServlets,所以JSP页面具有Java技术的所有好处,包括健壮的存储管理和安全性。作为Java平台的一部分,JSP拥有Java编程语言“一次编写,各处运行”的特点。JSP的应用模型利用JSP技术,动态信息由JSP页面来表现,JSP页面由安装在Web服务器或者使用JSP的应用服务器上的JSP引擎执行。JSP引擎接受客户端对JSP页面的请求,并且生成JSP页面作为对客户端的响应。JSP页面通常被编译成为JavaServlets,这是一个标准的Java扩展。页面开发人员能够访问全部的Java应用环境,以利用Java技术的扩展性和可移植性。当JSP页面第一次被调用时,如果它还不存在,就会被编译成为一个JavaServlets类,并且存储在服务器的内存中。这就使得在接下来的对该页面的调用中,服务器会有非常快的响应(这避免了CGIBIN为每个HTTP请求生成一个新的进程的问题)。JSP页面可以包含在多种不同的应用体系结构或者模型中,可以用于由不同协议、组件和格式所组成的联合体中。基于JSP的动态信息发布技术是一个开放的、可扩展的建立动态Web页面的标准。不论采用什么创建工具,开发人员都可以使用JSP页面来创建可移植的Web应用,在不同的Web应用服务器上运行。JSP语法JSP文件(扩展名为.jsp)可以包含指令(或称为指示语句)、Class-wide变量和方法、直接插入的Java代码(scriptlet)、访问JavaBean、变量数据的HTML模型、变量数据的Java表达式的组合。1JSP指令使用JSP指令(在内的)来指定所使用的脚本语言、Servlet实现的接口、Servlet扩展的类、Servlet导入的软件包。JSP指令的一般语法形式为:。其中有效的指令名为:(1)language:文件中所使用的脚本语言。此时对于Java程序设计语言来说,仅java为有效值和缺省值。该指令作用于整个文件。当多次使用该指令时,只有第一次使用是有效的。示例如下:。(2)Method:由嵌入的Java代码(scriptlet)生成的方法的名称。生成的代码会成为指定方法名的主体。缺省的方法是service。当多次使用该指令时,只有第一次使用是有效的。示例如下:。(3)Import:Servlet导入的Java语言软件包名或类名列表,该列表是用逗号分隔的。在JSP文件中,可以多次指定该指令来导入不同的软件包。示例如下:。(4)content_type:生成的响应的MIME类型。缺省值为text/html。当多次使用该指令时,只有第一次使用是有效的。该指令可用以指定在其中对页面进行编码的字符集。示例如下:。(5)mplements:用于生成Servlet实现的Java语言接口列表,该列表是用逗号分隔的。可以在一个JSP文件中多次使用该命令,以实现不同的接口。示例如下:11。(6)extends:Servlet扩展的Java语言类的名称。该类必须是有效的,且不能是一个Servlet类。该指令作用于整个JSP文件。当多次使用该指令时,只有第一次使用是有效的。示例如下:。2class-wide变量和方法使用和标记来说明Servlet类的class-wide变量和class-wide方法。一般语法如下:。/class-wide变量和方法的代码属性runat=server是必需的,它表明该标记是用于服务器端处理的。指定class-wide变量和方法的示例如下:/class-wide变量initi=0;Stringfoo=Hello;/class-wide方法privatevoidfoo()/该方法的代码3访问JavaBeanJSP对JavaBean的支持使您能通过Web站点重复使用组件。JavaBean可以是类文件或串行化Bean,也可由Servlet动态生成。请使用标记来创建一个Bean实例,以使从JSP文件的任何地方都可对该实例进行访问。标记的语法为:其中的属性及其含义如下:(1)name:用于在相应的范围(由scope属性指定)内查找Bean的名称。例如,这可能是用于存储Bean的会话(session)关键值。该值是分大小写的。(2)varname:用于在JSP文件中的任何地方引用Bean的名称。该属性是可选的。缺省值为name属性值。该值是分大小写的。(3)type:Bean的类文件名。该名称用于以代码说明Bean实例。缺省值为Object类型。该值是分大小写的。(4)Introspect:当该值为真时,JSP处理器检查将所有的请求属性,并调用与请求属性匹配的set属性方法集(该属性是在BeanInfo中传递的)。该属性的缺省值为是。12(5)BeanName:

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论