《2022年外文翻译外文资料和译文资料 .pdf》由会员分享,可在线阅读,更多相关《2022年外文翻译外文资料和译文资料 .pdf(15页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、(论文)译文-1-XX大学 XXXXXXX 外文资料和译文专业:软件工程班级:软件 XXXXX 姓名:XXXXX 学号:XXXXXXXXXXXXXX 指导教师:XXXXXXXX 2009 年 12 月 17 日名师资料总结-精品资料欢迎下载-名师精心整理-第 1 页,共 15 页 -(论文)译文-2-原文1.1 A JSP technology overview Lets begin by talking a little about how JSP pages work.Were going to keep it simple and focus on some of the basics.
2、For more information,see Resources for links to additional JSP technology information.In the traditional sense,JSP pages look very much like HTML pages,with a few extra tags.These tags allow the designer to embed Java code(not JavaScript)in the page itself.A Web application server,like the IBM WebSp
3、here Application Server,will intercept requests for JSP pages.Its tipped off to their existence by the pages extension:.jsp(not.html).The Web application server then preprocesses the JSP page,taking out the JSP tags and any embedded Java code,leaving only the HTML.The extracted JSP tags and embedded
4、 Java code are used to build a Java servlet(JSP page servlet)that runs the code and inserts the results back into the original page where the JSP tags used to be.The result is pure HTML.The Java is stripped out and run on the server before the requesting browser sees any result.We can apply the same
5、 principle to an XML page.Before the requester of the JSP page containing XML ever sees the XML(be it a browser or some other B2B application),the Java code is stripped out of the JSP page and used to generate additional content,which is inserted back into the page at the points where the JSP tags u
6、sed to reside.This feature gives you the ability to control exactly where new content is to be inserted,down to the character.Well look at how to make this work in a minute.First,lets consider why you might want to create dynamic XML using JSP.Why not simply write a Java application or servlet to ge
7、nerate the entire document?Why bother with JSP at all?The most important reason,providing only portions of an XML document are dynamic,is that it makes sense not to regenerate that static content for every request.Using a JSP page,the static XML within the page acts as a template that is filled out
8、by the dynamic content.Your Java code is tasked with generating only the content that might change over time-a more efficient approach.名师资料总结-精品资料欢迎下载-名师精心整理-第 2 页,共 15 页 -(论文)译文-3-As a practical matter,JSP pages allow you to separate tasks for which different developers will be responsible.In parti
9、cular,they allow you to better separate the data from the view,allowing you to add new presentations without affecting the logic.Imagine having one Java servlet that performs the business logic and redirects the resulting data to an appropriate JSP page based on the nature of the request.For example
10、,a servlet might redirect data to a JSP page containing WML when it detects a WAP phone browser making the request.It could also redirect the data to a JSP page containing HTML for standard browser requests.1.2 Benefits of JSPJSP pages are translated into servlets.So,fundamentally,any task JSP pages
11、 can perform could also be accomplished by servlets.However,this underlying equivalence does not mean that servlets and JSP pages are equally appropriate in all scenarios.The issue is not the power of the technology,it is the convenience,productivity,and maintainability of one or the other.After all
12、,anything you can do on a particular computer platform in the Java programming language you could also do in assembly language.But it still matters which you choose.JSP provides the following benefits over servlets alone:1.It is easier to write and maintain the HTML.Your static code is ordinary HTML
13、:no extra backslashes,no double quotes,and no lurking Java syntax.2.You can use standard Web-site development tools.Even HTML tools that know nothing about JSP can be used because they simply ignore the JSP tags.3.You can divide up your development team.The Java programmers can work on the dynamic c
14、ode.The Web developers can concentrate on the presentation layer.On large projects,this division is very important.Depending on the size of your team and the complexity of your project,you can enforce a weaker or stronger separation between the static HTML and the dynamic content.Now,this discussion
15、 is not to say that you should stop using servlets and use only JSP instead.By no means.Almost all projects will use both.For some requests in your project,you will use servlets.For others,you will use JSP.For still others,you will combine them with the MVC architecture.You want the appropriate tool
16、 for the 名师资料总结-精品资料欢迎下载-名师精心整理-第 3 页,共 15 页 -(论文)译文-4-job,and servlets,by themselves,do not complete your toolkit.1.3 Advantages of JSP Over Competing TechnologiesA number of years ago,Marty was invited to attend a small 20-person industry roundtable discussion on software technology.Sitting in the
17、 seat next to Marty was James Gosling,inventor of the Java programming language.Sitting several seats away was a high-level manager from a very large software company in Redmond,Washington.During the discussion,the moderator brought up the subject of Jini,which at that time was a new Java technology
18、.The moderator asked the manager what he thought of it,and the manager responded that it was too early to tell,but that it seemed to be an excellent idea.He went on to say that they would keep an eye on it,and if it seemed to be catching on,they would follow his companys usual embrace and extend str
19、ategy.At this point,Gosling lightheartedly interjected You mean disgrace and distend.Now,the grievance that Gosling was airing was that he felt that this company would take technology from other companies and suborn it for their own purposes.But guess what?The shoe is on the other foot here.The Java
20、 community did not invent the idea of designing pages as a mixture of static HTML and dynamic code marked with special tags.For example,ColdFusion did it years earlier.Even ASP(a product from the very software company of the aforementioned manager)popularized this approach before JSP came along and
21、decided to jump on the bandwagon.In fact,JSP not only adopted the general idea,it even used many of the same special tags as ASP did.So,the question becomes:why use JSP instead of one of these other technologies?Our first response is that we are not arguing that everyone should.Several of those othe
22、r technologies are quite good and are reasonable options in some situations.In other situations,however,JSP is clearly better.Here are a few of the reasons.1.3.1 Versus.NET and Active Server Pages(ASP).NET is well-designed technology from Microsoft.ASP.NET is the part that directly competes with ser
23、vlets and JSP.The advantages of JSP are twofold.名师资料总结-精品资料欢迎下载-名师精心整理-第 4 页,共 15 页 -(论文)译文-5-First,JSP is portable to multiple operating systems and Web servers;you arent locked into deploying on Windows and IIS.Although the core.NET platform runs on a few non-Windows platforms,the ASP part does no
24、t.You cannot expect to deploy serious ASP.NET applications on multiple servers and operating systems.For some applications,this difference does not matter.For others,it matters greatly.Second,for some applications the choice of the underlying language matters greatly.For example,although.NETs C#lang
25、uage is very well designed and is similar to Java,fewer programmers are familiar with either the core C#syntax or the many auxiliary libraries.In addition,many developers still use the original version of ASP.With this version,JSP has a clear advantage for the dynamic code.With JSP,the dynamic part
26、is written in Java,not VBScript or another ASP-specific language,so JSP is more powerful and better suited to complex applications that require reusable components.You could make the same argument when comparing JSP to the previous version of ColdFusion;with JSP you can use Java for the real code an
27、d are not tied to a particular server product.However,the current release of ColdFusion is within the context of a J2EE server,allowing developers to easily mix ColdFusion and servlet/JSP code.1.3.2 Versus PHP PHP(a recursive acronym for PHP:Hypertext Preprocessor)is a free,open-source,HTML-embedded
28、 scripting language that is somewhat similar to both ASP and JSP.One advantage of JSP is that the dynamic part is written in Java,which already has an extensive API for networking,database access,distributed objects,and the like,whereas PHP requires learning an entirely new,less widely used language
29、.A second advantage is that JSP is much more widely supported by tool and server vendors than is PHP.1.3.3 Versus Pure Servlets JSP doesnt provide any capabilities that couldnt,in principle,be accomplished with servlets.In fact,JSP documents are automatically translated into servlets behind the 名师资料
30、总结-精品资料欢迎下载-名师精心整理-第 5 页,共 15 页 -(论文)译文-6-scenes.But it is more convenient to write(and to modify!)regular HTML than to use a zillion println statements to generate the HTML.Plus,by separating the presentation from the content,you can put different people on different tasks:your Web page design expe
31、rts can build the HTML by using familiar tools and either leave places for your servlet programmers to insert the dynamic content or invoke the dynamic content indirectly by means of XML tags.Does this mean that you can just learn JSP and forget about servlets?Absolutely not!JSP developers need to k
32、now servlets for four reasons:(1).JSP pages get translated into servlets.You cant understand how JSP works without understanding servlets.(2).JSP consists of static HTML,special-purpose JSP tags,and Java code.What kind of Java code?Servlet code!You cant write that code if you dont understand servlet
33、 programming.(3).Some tasks are better accomplished by servlets than by JSP.JSP is good at generating pages that consist of large sections of fairly well structured HTML or other character data.Servlets are better for generating binary data,building pages with highly variable structure,and performin
34、g tasks(such as redirection)that involve little or no output.(4).Some tasks are better accomplished by a combination of servlets and JSP than by either servlets or JSP alone.1.3.4 Versus JavaScript JavaScript,which is completely distinct from the Java programming language,is normally used to dynamic
35、ally generate HTML on the client,building parts of the Web page as the browser loads the document.This is a useful capability and does not normally overlap with the capabilities of JSP(which runs only on the server).JSP pages still include SCRIPT tags for JavaScript,just as normal HTML pages do.In f
36、act,JSP can even be used to dynamically generate the JavaScript that will be sent to the client.So,JavaScript is not a competing technology;it is a complementary one.It is also possible to use JavaScript on the server,most notably on Sun ONE 名师资料总结-精品资料欢迎下载-名师精心整理-第 6 页,共 15 页 -(论文)译文-7-(formerly iP
37、lanet),IIS,and BroadVision servers.However,Java is more powerful,flexible,reliable,and portable.Versus WebMacro or Velocity JSP is by no means perfect.Many people have pointed out features that could be improved.This is a good thing,and one of the advantages of JSP is that the specification is contr
38、olled by a community that draws from many different companies.So,the technology can incorporate improvements in successive releases.However,some groups have developed alternative Java-based technologies to try to address these deficiencies.This,in our judgment,is a mistake.Using a third-party tool l
39、ike Apache Struts that augments JSP and servlet technology is a good idea when that tool adds sufficient benefit to compensate for the additional complexity.But using a nonstandard tool that tries to replace JSP is a bad idea.When choosing a technology,you need to weigh many factors:standardization,
40、portability,integration,industry support,and technical features.The arguments for JSP alternatives have focused almost exclusively on the technical features part.But portability,standardization,and integration are also very important.For example,the servlet and JSP specifications define a standard d
41、irectory structure for Web applications and provide standard files(.war files)for deploying Web applications.All JSP-compatible servers must support these standards.Filters can be set up to apply to any number of servlets or JSP pages,but not to nonstandard resources.The same goes for Web applicatio
42、n security settings.Besides,the tremendous industry support for JSP and servlet technology results in improvements that mitigate many of the criticisms of JSP.For example,the JSP Standard Tag Library and the JSP 2.0 expression language address two of the most well-founded criticisms:the lack of good
43、 iteration constructs and the difficulty of accessing dynamic results without using either explicit Java code or verbose jsp:useBean elements.1.4 Misconceptions About JSP Forgetting JSP Is Server-Side TechnologyHere are some typical questions Marty has received(most of them repeatedly).?Our server i
44、s running JDK 1.4.So,how do I put a Swing component in a JSP 名师资料总结-精品资料欢迎下载-名师精心整理-第 7 页,共 15 页 -(论文)译文-8-page?How do I put an image into a JSP page?I do not know the proper Java I/O commands to read image files.?Since Tomcat does not support JavaScript,how do I make images that are highlighted whe
45、n the user moves the mouse over them?Our clients use old er browsers that do not understand JSP.What should we do?When our clients use View Source in a browser,how can I prevent them from seeing the JSP tags?All of these questions are based upon the assumption that browsers know something about the
46、server-side process.But they do not.Thus:?For putting applets with Swing components into Web pages,what matters is the browsers Java version the servers version is irrelevant.If the browser supports the Java 2 platform,you use the normal APPLET(or Java plug-in)tag and would do so even if you were us
47、ing non-Java technology on the server.?You do not need Java I/O to read image files;you just put the image in the directory for Web resources(i.e.,two levels up from WEB-INF/classes)and output a normal IMG tag.?You create images that change under the mouse by using client-side JavaScript,referenced
48、with the SCRIPT tag;this does not change just because the server is using JSP.?Browsers do not support JSP at all they merely see the output of the JSP page.So,make sure your JSP outputs HTML compatible with the browser,just as you would do with static HTML pages.?And,of course you need not do anyth
49、ing to prevent clients from seeing JSP tags;those tags are processed on the server and are not part of the output that is sent to the client.Confusing Translation Time with Request TimeA JSP page is converted into a servlet.The servlet is compiled,loaded into the servers memory,initialized,and execu
50、ted.But which step happens when?To answer that question,remember two points:?The JSP page is translated into a servlet and compiled only the first time it is accessed after having been modified.名师资料总结-精品资料欢迎下载-名师精心整理-第 8 页,共 15 页 -(论文)译文-9-?Loading into memory,initialization,and execution follow the