1、 中英文资料翻译Withthe popularityofthe InterNETapplications,a variety of WebInformation SystemHas becomeapressingissue.EstablishtheessenceofWebinformation systemsDevelopment of aWebrepository(databaseas the core ofa variety ofWebletterInformation storage)as the coreWebapplications.Currently, the Webreposit
2、orydevelopmenttechnologyOperationofa wide range ofdifferent characteristics.Various periodsat all levels,a variety of purposesTechnologyco-exist,dizzyingmirrorchaos, it is difficult tochoose.MorepopularJavaof ServetWebrepositorydevelopmentprograma more practicalOfchoice.Servletisrunningtheappleton t
3、he Web server,can be completedXuMulti-clientAppletcan not completethe work, which runson the serverandclientsNoend, do notdownloaddo notbytheclientsecurity restrictions,therunningspeedGreatly increasedAnd AppletrunninginabrowserandextendthebrowsersabilitysimilarLike,Servthe letruninthe Webservertoen
4、ableJavaServthe letengineAnd expandthecapacityoftheserver.Therefore, we can sayServthe letisruninAppleton a Web server,Servthe letJav a Ser vlet APIAndJavaprogramofclassesand packages.1 Servletaccessmodel2 Servthe let, there are threeaccess models:(1)an accessmodel1browser toWeb servertoissuearetrie
5、valrequest.2the Webserverafterreceipt of the request,therequestforwarded to theServle tengine.3 Serletengineto perform the requestedtheSer vletanddirectlythrough JDBC4ServletthroughJDBCtoretrievesearch resultstogeneratethehtmlpage andPageback totheWeb server. 5the Webserverthe pageissentback to the
6、browser.(2)The secondaccessmodel1browser toWeb servertoissuearetrievalrequest.2the Webserver receives the requestafter therequestforwarded totheof Servthe letengine.3 Serv letengineto perform therequestthetheSer vletandretrievesentJa,vabeanaccesstothedata.4dataaccesstheJa vabeansearchable databaseth
7、rough JDBCinformationAndfrom the search resultsstoredinitself.5Servletremovesearch resultsfromthedataaccessJavabeangenerateHtmlpage andHtml ofpageback to thewebserver.6the Webserverthe pageissentback to the browser.(3)The thirdaccess model1 Abrowserissuearetrievalrequestto the Web server.2 Webserver
8、 receives the requestafter therequestforwarded totheof Servthe letengine.Of Servletengineto perform the requestedServletdirectlythrough JDBCinspection3 Thecabledatabase andsearch resultsare stored in theresult is storedtheJav abeaninto.Javabean,4.Servthe letfromtheresults are storedtoremovethesearch
9、 resultsandJSP filestoformattheoutputpage.2Servletfunctionality andlife cycle2.1 Servletfunctions(1)Createand returndynamic Web pagesbasedoncustomer requests.(2)createcan be embedded intoexistingHTML pagesas part ofHTMLPage (HTfragment)ofthe ML.(3)andotherserver resources(including databasesandappli
10、cationsbasedontheJavaProgram)to communicate.(4)tohandlemultipleclientconnections, receivingtheinputofmorethanoneclient, andThe resultsbroadcast tomultiple clients.Forexample, Servletis a multi-participantGame server.(5)of MIMEtypefilterinformationonthespecial handling, such asimageConversion andserv
11、er-sideinclude(SSI).(6)customprocessingavailabletoall servers inthe standardroutine.2.2Servlet lifecycleServletlife cyclebeginswithit intotheWeb servers memoryAndendinthetermination orre-loadedServthe let.(1) load.Loadtheservletat the followingtimes:1. If you have configuredautomaticloadoption, andt
12、henstarttheWeb serverautomatically loaded2. AfterthestartoftheWeb server,theclientServthe letissuedforthefirsttime, pleaseDemand.3. ReloadServthe let.LoadedServlet, Web serversto create aservlet instance,andServletsinit () methodiscalled.Servletinitializationparametersintheinitialization phase,Thenu
13、mberis passedto the Servletconfiguration object.(2) terminateWhentheWeb serverno longerneedstheservlet,orreloadServletA new instance oftheservercallsServthe letsdestroy () method,remove it from theMemorydeleted.3 How tocallServletMethodof ServletiscalledTotalfive kinds:callin the URLintheform Tagcal
14、l,call,inHTthe MLpageintheJSP filesCall,callin an ASP file.The followingitemizedto be introduced.(1) call theservletin the URL.Simplyinput formatin the browserashttp: yo ur webser verthe sametheservletnamename/ servletpath /servletthe URLtoThesitecanbe.Ofwhich:your webser ver nameistorefer totheServ
15、letwhere theWeb servername,the servletpath is thepathrefers to theServlet,the servletThenamerefers totheServletreal nameoran alias.(2) call the Servlet tagsCallof Serthe letthethetagallows users toinput dataon the Web page,andinput datasubmitted to thevletof Ser.Servthe letwillbesubmittedto receive
16、datain different ways.For example: place thetext input areatags,buttons andother logos(3) in the HTML pagetocalltheservlet.Usemark tags,no need to createa completeHTML page.Instead,theservletoutputisonlypartoftheHTMLpage(HTMLfragment)anddynamicallyembedded into thestatic textintheoriginalHTML page.A
17、ll this happenedon the serverandsentto the useronlythe resulting HTML page.tagcontainedintheoriginal HTMLpage.Servlet willbe invokedinthese two markersandtheSer vletresponsewillcoverthese two markersbetweenallthingsandmarkitself, for example:SERVLET NAME= “my serv let ”CODE= “my serv let .class”CODE
18、BASE= “u r l”initpar am= “v alue”PARAM NAME= “parm1”VALU E= “v alue1”PARAM NAME= “parm2”VALU E= “v alue2”/SERVLET (4) call theservletintheJSP files.CallintheJSPfileformatusedbytheServletandHTMLpageto callexactly the same.Andtheprinciplesare identical.OnlyreconcileitsdynamicJSPfile is not astatic HTM
19、Lpage.(5) in an ASP filecallstheservlet.If youMicrosoftInternetInformation-Server(IIS)on thelegacyof the ASP file,andcan not beASP filestransplantedintoaJSP file,you can usetheASP filetoof Servletiscalled.But it must bethroughaspecialActiveXcontrol,an ASP fileis only throughit cancalltheservlet.4 Se
20、rvletHowtouseConnectionManagerto efficiently managethe database connection(1) the functionalityoftheConnection Manager.Fornon-Web applications,Web-basedapplicationaccess to the databasewill lead tohigherandunpredictableoverhead, which isdue tomore frequentWeb usersconnect anddisconnect.Normally conn
21、ectedtothe resources usedanddisconnect from the databasewill far exceedtheresourcesusedintheretrieval.Connection Managerfunction isto minimizetheadditionaloccupancyoftheusers ofthedatabaseresourcesto achievethebest performanceofdatabase access.Connection Managersharingoverheadthrough the establishme
22、nt oftheconnection poolwill connectusersServletavailableto multiple usersrequest.Inotherwords, each userrequestonly theconnect /disconnectwitha small portionoftheoverheadcosts.Initialresourcesto establishtheconnectionofthebufferpool,therestoftheconnect /disconnectoverheadis not big, becausethis is o
23、nlyreusetheexistingconnection.Servthe letin the following mannerusing theconnection pool:WhenauserthroughRequestWebServthe letthe letServusean existingconnectionfrom the buffer poolNext,this means thattheuser requestsdo not causetheconnection to the databasesystemoverhead.InAftertheterminationofserv
24、the letitconnectto returntothepoolfor itsConnection ManagerTheSer vlet.Thus,theuserrequestdoes not causethe databaseis disconnectedOf system overhead.Connection Manageralso allows userstobe able to controltheconcurrencyofthedatabase productsevenThenthe number.Whenthedatabaselicense agreementlimitthe
25、number of users,this featureisVery useful.Createa bufferpoolfor the database, andconnection managementBufferingpoolmaximumnumber of connectionsparameterset tothedatabaseproduct licenselimitGivenmaximum number of users.If you useother programswithoutConnection ManagerconnectionsDatabase, you can notg
26、uarantee that the methodiseffective.(2) the structure ofthe Connection Manager.(3) Connection Manager connection pool to maintain a connection to a specific database is open.Step 1: When the first Serv the let trying to Connection Manager communications is loaded by the Java Application Server Conne
27、ction Manager.As long as the Java application server running the Connection Manager has been loaded. Step 2: The Java application server passes the request to a servlet.Step 3: Servlet Connection Manager requests a connection from the pool.Step four: the buffer pool to Ser vlet allocated a pool of e
28、xisting idle connection.Step 5: servlet to use to connect a direct dialogue with the database, this process is the standard API for a particular database.Step 6: the database through Ser vlet the connection returns data.Step 7: When the Servlet end to communicate with the database, servlet connectio
29、ns returned to the connection manager pool for other servlet uses. Step 8: Servlet Jav a application server to the user sends back response.Servlet requests a connection, if the buffer pool, there is no idle connection, then the connection manager directly communicate with the database.Connection Ma
30、nager will: Step 9: to the database requests a new connection.Step 10: Add connections to the buffer pool.If the buffer pool is connected to the prescribed ceiling, connect to the serverWill not be a new connection to join the buffer pool(3) the performance characteristics of the Connection Manager.
31、Buffer pool to create a new connection is a high overhead tasks, new connections will use the resources on the database.Therefore, the Connection Manager the best use of existing connections of the buffer pool to meet the request of the Servlet.Meanwhile, the connecting tubeThe processor must be as
32、much as possible to minimize the buffer pool idle connections, because this is a great waste of system resources.Connection Manager Serv the let with the implementation of these minimize and maximize task.Connection Manager to maintain each connection verification time stamp, and recently used tags
33、and use the logo.When the a Ser vlet first the connection, connection verification time stamp, and most recent time stamp is set to the current time, the connection is being used flag is set to true.Connection Manager can be removed from a Serv the let a long-unused connections, this length of time
34、specified by the Connection Manager, the longest cycle parameters.Connection Manager can view recently used mark is being used to connect.If the time between the most recently used time and time difference is greater than the longest cycle configuration parameters, the connection will be considered
35、to be a residual connection, which indicates Serv the let take its discontinued or no response.Residual connection will be returned to the pool for other Ser vlet, it is being used flag is set to false, authentication and time stamp is set to the current time.If Ser vlet is ready within a longer per
36、iod of time to use the connection with the database several timesCommunications, you must code to the Serv the let, so that each time you use to connectConfirm that it still occupies this connection.Connection Manager can be removed from the buffer pool idle connections, because theyWould be a waste
37、 of resources.In order to determine which connection is idle, Connection Manager will checkInvestigation connected the sign and time stamp, this operation is connected by periodic access toBuffer pool information.Connection Manager checks have not been any Ser vlet makeWith the connections (these co
38、nnections is to use the logo is false).If you have recently usedBetween time and the current time difference exceeds a maximum idle time configuration parameters, theThat the connection is idle.Idle connection will be removed from the buffer pool, down toMinimum number of connections configuration p
39、arameter specifies the lower limit value.翻译:随着Inter net 的普及应用, 各种Web 信息系统的建立已成为一个迫在眉睫的问题。建立Web 信息系统的实质就是开发一个以Web 信息库( 以数据库为核心的多种Web 信息存储) 为核心的Web 应用系统。目前,Web 信息库开发技术的种类繁多, 特点各异。各个时期、各个层面、各种用途的技术并存, 令人眼花镜乱, 难以选择。而目前较为流行的基于Java Ser vet 技术就是Web 信息库开发方案的一种比较实用的的选择。Serv let 是运行在Web 服务器上的Applet, 可以完成许多客户A
40、pplet 不能完成的工作, 它运行在服务器上, 与客户端无任何关系, 不用下载不用受到客户端安全限制, 运行速度大大提高。与Applet 运行在浏览器上并扩展浏览器的能力相类似, Serv let 运行在启用Java Serv let 引擎的Web 服务器上并扩展该服务器的能力。因此, 可以说Serv let 就是运行在Web 服务器上的Applet, Serv let 就是使用Jav a Ser vlet API及相关类和软件包的Jav a 程序。1Servlet 的访问模型Serv let 有三种访问模型:( 1) 第一种访问模型。1 浏览器向Web 服务器发出检索请求。2 Web 服务
41、器收到请求后将请求转交给Ser vlet 引擎。3 Serv let 引擎执行所请求的Ser vlet 并通过JDBC 直接检索数据库中的信息。4Ser vlet 通过JDBC 取回检索结果生成html 页面并将页面送回Web 服务器。5 Web 服务器将页面发送回浏览器。 ( 2) 第二种访问模型1 浏览器向Web 服务器发出检索请求。2 Web 服务器收到请求后将请求转交给Ser v let 引擎。3Serv let 引擎执行所请求的Ser vlet 并将检索式发送给数据访问Ja vabean。4数据访问Ja vabean 通过JDBC 检索数据库中的信息并将从检索结果存储在自身之中。5
42、Ser vlet 从数据访问Javabean 中取出检索结果生成Html 页面并将Ht ml 页面返回给w eb 服务器。6Web 服务器将页面发送回浏览器。( 3) 第三种访问模型( 见图3) 。1浏览器向Web 服务器发出检索请求。2 Web 服务器收到请求后将请求转交给Ser v let 引擎。3 Ser vlet 引擎执行所请求的Serv let 直接通过JDBC 检索数据库并将检索结果存储在结果存储Jav abean 之中。4 Ser v let 从结果存储Jav abea n 中取出检索结果并用JSP 文件格式化输出页面。5 将格式化后的输出页面发送给Web 服务器。6 Web 服
43、务器将页面发送回浏览器。2Servlet 的功能与生命周期2. 1Ser vlet 的功能( 1) 创建并返回一个基于客户请求的动态Web 页面。( 2) 创建可嵌入到现有HTML 页面中的一部分HTM L页面( HT ML 片段) 。( 3) 与其它服务器资源( 包括数据库和基于Jav a 的应用程序) 进行通信。( 4) 处理多个客户机的连接, 接收多个客户机的输入, 并将结果广播到多个客户机上。例如, Ser vlet 可以是多参与者的游戏服务器。( 5) 对特殊的处理采用MIM E 类型过滤资料, 例如图像转换和服务器端包括( SSI ) 。( 6) 将定制的处理提供给所有服务器的标准
44、例行程序。例如, Ser vlet 可以修改如何认证用户。2. 2Ser vlet 的生命周期Serv let 的生命周期始于将它装入Web 服务器的内存时, 并在终止或重新装入Serv let 时结束。( 1) 装入。在下列时刻装入Ser vlet:1 如果已配置自动装入选项, 则在启动Web 服务器时自动装入。2 在Web 服务器启动后, 客户机首次向Serv let 发出请求时。3 重新装入Serv let 时。装入Serv let 后,Web 服务器创建一个Ser vlet 实例并且调用Serv let 的init( ) 方法。在初始化阶段, Serv let 初始化参数被传递给Ser
45、v let 配置对象。( 2) 终止。当Web 服务器不再需要Serv let , 或重新装入Ser vlet 的新实例时, 服务器会调用Serv let 的destr oy ( ) 方法, 将其从内存中删除。3如何调用Servlet调用Ser vlet 的方法共有五种: 在URL 中调用、在窗体Form标记中调用、在HT ML 页面中调用、在JSP 文件中调用、在ASP 文件中调用。下面将逐项加以介绍。( 1) 在URL 中调用Serv let。只需在浏览器中输入格式像http: yo ur webser vername / serv let path/ ser vlet name 一样的Serv let URL 地址即可。其中: yo ur webser ver name 是指Serv let 所在的Web 服务器名, serv let pat h 是指Serv let 的路径, ser vletname 是指Serv let 的真实名字