JSP技术---外文文献_第1页
JSP技术---外文文献_第2页
JSP技术---外文文献_第3页
免费预览已结束,剩余9页可下载查看

下载本文档

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

文档简介

1、外文文献JSP Tech no logy and ServletsJSP profiled design,Web-based applicationdevelopme ntisrapid andasy.Web server in thefaceofvisits JSPhe firstimpleme ntati ongether with the results ments in HTML code withofofthepage request, of, and the ntoproceduresimplementationof JSP docuthe retur n to the custo

2、mer. InsetheJSP (JavaServer Pages) is initiated by Sun Microsystems,Inc.,withmany companies to participatein th(e establishme ntof adynamic web page technicalstandards.JSPtechno logysomewhat similar to ASP tech no logy,it isinthetraditi onalHTMLweb page document (*. htm, *html)toin serttheJavaprogra

3、m ming paragraph (Scriptlet)andJSPtag(tag),thusJSP documents (*. jsp).UsingJSP developme ntof theWebapplicati onis cross that canrunonLinux,is also availablefor otheroperat ingsystems.JSPtech no logyto usethe Javaprogram ming Ian guagepreparedby the category ofXML tagsand scriptlets,toproduce dyn am

4、ic pages package process ingI logic.Pagealsovisit bytags and scriptletsexist inthe servicessideofthe resources of logic.JSP pagelogic and webpagedesig n and display separati on,support reusablecomp onen t-basert the Java program ming operatio nof the database can bereorie nted websites, in order to

5、achieve the establishme n t of dynamic pages needed to function.JSPand Java Servlet,is intheimpleme ntatio n ofthe server, usually returned to the clie nt is an HTML text, as long as the clie n tbrowserwillbe able tovisit.JSP 1.0 specificati onof the finalvers ionislaun chedin September 1999, Decemb

6、er has introduced1.1 specificat ions. At present relatively new is JSP1.2 norms, JSP2.0 n orms of the draft has also been introduced.JSP pages fromHTML code and Java code embedded in one of the comp one nts.JS scriptIan guage syn opsisJS is javascrip, Javascript is one kind the script la nguage whic

7、h comes by the Netscape LiveScript development, the mai n purpose is to solve the server termi nalIan guage, for in sta neePerl,carry-overspeedquesti on.At thattime served theendto need tocarry on theconfirmation to the data, because the network speed was quite slow , on ly the n 28.8kbps, thecon fi

8、rmati onstep waste's timewere too many. Therefore Netscape browser Navigator has jo ined Javascript, has provided the data con firmati onbasicfun cti on.The JavaScript official name is“ ECMAScript”.This stan dard by ECMA orga ni zatio ndevelopme nt and maintenan ce.ECMA262 is the officialJavaScr

9、ipt standard.This standardbased on JavaScript(Netscape)andJScript (Microsoft).Netscape (Navigator 2.0)BrendanEichhas inven ted thisIan guage, started from 1996, already appeared inallNetscape and in the Microsoftbrowser.TheECMA262 developme ntbega nin 1996, in 1997 July, the ECMA generalmeeting has

10、accepted its first editi on.The script uses one specific descriptiveIanguage,rests on certa in formcompilati onto be possible the execution docume nt,is alsocalledasgreator the batchrun document. Thescriptusuallymaytransfertemporarilyby theapplicati onprocedure andcarry out.Each kind ofscriptpresent

11、 widely isappliedinthe homepage design,because the script not only may reduce the homepage the scale and raises the homepage browsingspeed, moreover may enrich the homepage performanee,like animation, sound and soon. Cites a most com mon example, whe n we click in the homepage theEmail address can t

12、ransfer Outlook Expressor the Foxmail this kind of mail software automatically, isrealizes through the script fun cti on.Also becauseofscript these characteristics, the human who harbors ulterio rmotivesby someare oftenusing. Forexample joins some destructi on computer system's order in the scri

13、pt, like this works as the user browsing homepage, once transfers this kindof script,will the n cause the user the system to come under the attack. Therefore the user should a ct accordingto visitshomepage the trust degree selectivesecurity rank, specially regard ing these itself content o n the ill

14、egal homepage, do not permit the use script eas ily. Through “the safe establishment ” the dialog box, th e choice “the script ”under optioneach kind of establishment may with ease realize to script being forbid and begi ns using.JSP and ServletsThe tech no logyof JSP and Servlet is the most importa

15、nt tech no logywhich use Javatech no logyto exploit request of server, and it is also thesta ndardwhich exploit bus in ess applicati on.Java developers prefertouseit for avarietyofreas ons,oneof which is already familiarwiththeJavaIan guageforthe developme ntofthistech no logyareeasyto lear nJava to

16、 the otheris"apreparati on,runeverywhere" tobring the con ceptofWebapplicati ons,Toachieve a "on e-prepared everywhererealized."And more importantly, if followed some of theprinciplesof good design, itcan be said of separat ingand content to create high-quality, reusable,easy tom

17、aintainand modify the applicati on.Forexample,if thedocumentin HTML embedded Java codetoomuch (script), will lead the developedapplicati onis extremely complex, difficult to read, it is not easy reuse, but alsoforfuture maintenanceand modificatio nwill alsocause difficulties.In fact, CSDN the JSP /

18、Servlet forum,canoftensee some questions, the code isverylong,can logic is not very clear, a largenumber of HTML andJava code mixed together. This is therandom developmentof the defects.Earlydynamic pages mainly CGI (Common Gateway Interface,public Gateway In terface)tech no logy,you can use differe

19、ntIanguagesof the CGIprograms,such as VB,C /C+ + or Delphi, and so on. Though the tech no logy of CGI isdevelopedand powerful, becauseof difficulties inprogram ming, and low efficie ncy, modify complex shortco min gs,itis graduallybeingreplacedby the trend. Of all thenew tech no logy,JSP/ Servletwit

20、hmoreefficie ntandeasy to program,morepowerful,moresecureand has a goodportability,they have bee nmanypeoplebelievethat thefuture is the mostdyn amicsiteof thefuturedevelopment of tech no logy.Similar to CGI, Servlet support request / resp onse mod el. Whe n a customer submit a request to the server

21、, the server prese nted the request Servlet, Servlet resp on sible for han dli ng requests and gen eratea resp on se,and the ngave theserver, and the n from theserversentto thecustomer.And the CGI isdiffere nt,Servletnotgen eratea new process, butwith HTTP Server at thesameprocess. Itthreadsthrought

22、he use of tech no logy,reducetheservercosts.Servlethan dli ngof the requestprocessisthis:When received from theclie nt'srequest,calli ngservicemethods,the method ofServlet arrivalofthefirstjudgement is what type of request (GET / POST / HEAD-), then calls the appropriate treatment (DoGet / doPos

23、t / doHead ) and gen eratea resp on se.Although such a complex,in fact, simply said to Servlet isa Javaclass.And the general category ofthe difference is that thistype operati ngin a Servletcon tai ner, which can provide session management and targeted life cycle management. So thatwhen you use the

24、Servlet, youcan get all theben efitsof the Java platform, in cludi ngthe safety of the management, use JDBC access the datab ase and crossplatform capability. Moreover, Servlet using t hread, and can develop more efficientWeb applications.JSP tech no logy is a key J2EE tech no logy, itat a higher le

25、vel of abstracti onof a Servlet. Itallows conventional static and dyn amic HTML contentgen eratedby comb iningan HTML page lookslike, butasa Servlet to run. There are many commercial application server support JSP tec hnology, such as BEA WebLogic, IBM WebSphere, JRun, and s oon. JSP and Servletusem

26、orethan simple.If youhavea JSP supportfor Web servers, and a JSP document, youcan put itFangdao any static HTML files can be placed, do not have to compile, do not have to pack, do not have to ClassPath sett in gs, you can visit as ordi naryWeb It did visit, the server will automatically help you to

27、 do other work.JSP document lookslikean ordinary staticHTML document, but in sidecontains anu mber of Javacode.It uses.Jsp the suffix, usedtotell the serverthisdocume ntin need of special treatment.When we visit a JSP page,the docume nt will first be tran slatedin toa JSP engineJava source files, is

28、 actually a Servlet, and compiler, and the n, like other Servlet, from Servlet engine to ha n dle.Servlet engine of this type loadi ng,han dli ngrequests from customers, and the resultsretur nedto the customer.Afterano thervisitthispageto the customer,as Iongas the papertherehavebee nnocha nges,JSPe

29、ngine hasbee n loadeddirectlycalltheServlet.Ifyouhave already bee n modified,itwillbeoncej aga intheimpleme ntation of the above process, tran slate,compile and load. In fact, this is the so-called "firstpers on to puni shme nt." Because when the first visit to the implementation ofa serie

30、s of the above process, so willspend some timeafter such a visit would not.Java servlets offer a powerful API that provides acces s toallthe in formati on abouttherequest, thesessi on,andtheapplication. combiningJSPwith servletsletsyou clearly separate the applicati on logic from the prese nta tion

31、of the applicati on;in other words, it lets you usethe most appropriate component type for the roles of Model, View and Con troller.Servlets,Filters, and Liste nersA servletis a Java classthatextends a server withfun cti on ality forprocess ing a requestand produc ing a resp on se. It'simpleme n

32、ted using theclasses and in terfacesdefinedby the Servlet API. The API consistsof two packages:the javax.servlet package containsclasses and interfacesthatare protocoli ndepe ndent, whilethe javax.servlet.http package provides HTTP-specific exte nsions and utility classes.ectly or by exte ndingone o

33、f the support classes. This interfacedefines the methods used by the web container toman age and in teractwith theservlet. A servlet forprocessingHTTP requests typicallyexte nds thejavax.servlet.http.HttpServletclass. This class impleme ntsthe Servlet in terfaceand provides additi onal methods suita

34、ble for HTTP processing.Servlet LifecycleThe webcontainer man ages all aspects oftheservlet'slifecycle. It creates an in sta neeof the servlet class when n eeded,passesrequests tothe in sta neeforprocess ing,and eventually removes the instanee.For an HttpServlet,the container calls thefollowingm

35、ethods at the appropriate times in the servlet lifecycle.Besides the doGet( ) and doPost( ) methods, there are m ethods correspondingto the other HTTP methods: doDelete(),doHead( ),doOptions(), doPut( ), and doTrace( ). Typically you don't impleme nt these methods; the HttpServle t class already

36、 takes care of HEAD, OPTIONS, and TRACE r equests in a way that'ssuitableformostservlets,andthe DELETE and PUT HTTPmethodsarerarely used ina web applicati on.It's importa nt to realize that the container creates onlyone instaneeof each servlet.This means that the servletmust bethreadsafe -ab

37、le tohan dlemultiplerequestsat the same time, eachexecuti ngas aseparatethreadthrough theservletcode.Withoutgett inglost indetails,you satisfythisrequireme ntwithregardstoin sta neevariables if you modify the refere need objects only in the init( ) and destroy( ) methods, and just read them in the r

38、equest process ing methods.a ServletCompili ngand In stalli ngTo compile a servlet, you must firstensure that youhave the JAR file containing all Servlet API classes in the CLASSPATHenvironmentvariable. The JAR file is distributed with all web containers.Tomcat includesit in afilecalled servlet.jar,

39、locatedin the com mon/libdirectory.On a Windows platform, you include the JAR file inthe CLASSPATH.Read ing a RequestOne of the arguments passed to the doGet( ) and doPo st( ) methods is an object thatimpleme ntsthe HttpServletRequest in terface.This in terface defi nes methods that provide access t

40、o a wealth of in formatio nabout the request.Gen erat ing a Resp onseBesides the request object, the container passes an objec t that impleme nts the HttpServletResp onsein terface as anargume nt to the doGet( ) and doPost( )methods. This interfacedefinesmethods for getting awriteror streamfortheres

41、ponsebody. It also definesmethodsfor settingthe resp onse status code and headers.Using Filters and Liste nersThe servlet specificationdefinestwo component types beside servlets:filters and listeners. These two types werein troducedin the Servlet 2.3specificati on,so if you'reusing a container t

42、hat does n't yet support thisvers ionof thespecificati on,rm afraid you're out of luck.FiltersA filter is a component that can intercept a request targeted for a servlet, JSP page, or static page, as well as the resp onse before it's sent to theclie nt.Thismakes it easy to centralize tas

43、ks that apply to all re quests, such as access control,logging,and charging forthe content or the services offered by the applicati on. A filterhasfull access tothe bodyand headers ofthe requestandresp on se, so it can also perform varioustransformations.One example is compressing theresponse body i

44、ftheAcceptla nguagerequest headerin dicatesthatthe clie ntcan han dle a compressed resp on se.Afiltercan be applied to either aspecificservletor to all requests matchi ng a URL patter n,such as URLs startingwith the same path elements or having the same exte nsion.Liste nersListe ners allow your app

45、licati on to react to certa in e ven ts. Prior to Servlet 2.3, you could han dle on ly sessio n attribute binding events (triggered when an object was added or removed from a session). You could do this by letting the object saved as a sessionattributimplementtheHttpSessi on Bi ndin gListe ner in te

46、rface. With the new in terfa ces in troduced in the 2.3vers ionof thespecificati on, you can createliste nersfor servlet con text and sessi onIifecycleeve ntsas well as sessi onactivati onand passivation eve nts(used by a containerthat temporarily saves sessi on stateto diskor migratesa sessi on toa

47、no ther server). A n ewsessi onattributeeve ntliste neralso makes itpossible to deal withattribute bindingeve nts forallsessi onsin one place,in steadof plac ing in dividuallistener objectsineachsessi on.The new types oflistenersfollow thestandardJava event model.Inotherwords,a liste neris a class t

48、hatimpleme nts one or more of theliste nerin terfaces.The interfaces define methods that correspond to events. The lis tener class is registered with the container when the app licati onstarts, and the containerthe ncalls the eve nt methods at the appropriate times.In itializi ngShared Resources Usi

49、 ng a Liste nerBea ns like this typically n eed to be in itializedbefore they can be used. Forinstanee,they may need a referenee to a database orsome otherexternaldata sourceand may create an initial informationcache in memory toprovide fast access even to the first request for data. You can include

50、 code forin itializati onoftheshared resources inthe servletand JSP pagesthatn eedthem, but a moremodular approach is to placeallthiscode in one placeand let theother parts oftheapplicati onwork on theassumpti on that the resources are already in itialized and available. An applicati onlifecyclelist

51、e neris a perfect tool for this type of resourcein itializatio n.This type of liste ner, with methods called by the containerwhen the application starts and when it shuts down.Picking the Right Component Type for Each TaskThe Project Billboard applicati onin troducedis a fairly complex applicati on.

52、 and bus in ess logic authe nticate users, In real life, itHalf the pages are purecontrollerprocess ing, it accesses a database to and most pages require access control would likely contain even more pages,forinstanee,pages for access to a shared document archive, time schedules, and a set of pages

53、foradm ini stration. As theapplicationevolves, it may become hard to maintain as a pure JSP application. It's easy to forget to includethe access controlcode in new pages.This is clearly an applicati onthat can ben efitfromusing acomb in atio n of JSP pages andthecomp onenttypesdefi ned by the s

54、ervlet specificati onforthe MVCroles.Let'slook at the main requirementsandsee howwe canmap them to appropriatecomponent types:Database access should be abstracted, to avoidkno wledge of a specific dataschema ordatabaseenginein morethan one partof theapplicati on:bea nsin therole ofModel can beused toaccomplish this.The database access beans must be made available to a ll other parts of th

温馨提示

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

评论

0/150

提交评论