外文翻译 外文资料和译文
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
. .
XX大学XXXXXXX
外文资料和译文
专业:软件工程
班级:软件XXXXX
姓名:XXXXX
学号:XXXXXXXXXXXXXX
指导教师:XXXXXXXX
2009 年 12 月 17 日
原文
1.1 A JSP technology overview
Let's begin by talking a little about how JSP pages work. We're going to keep it simple and focus on some of the basics. 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 WebSphere Application Server, will intercept requests for JSP pages. It's tipped off to their existence by the page's 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 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 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 used to reside. This feature gives you the ability to control exactly where new content is to be inserted, down to the character.
We'll look at how to make this work in a minute. First, let's consider why you might want to create dynamic XML using JSP. Why not simply write a Java application or servlet to generate 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 by the dynamic content. Your Java code is tasked with generating only the content that might change over time -- a more efficient approach.
As a practical matter, JSP pages allow you to separate tasks for which different developers will be responsible. In particular, 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, 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 JSP
JSP pages are translated into servlets. So, fundamentally, any task JSP pages 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, 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: 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 code. The Web developers can concentrate on the presentation layer.