【正文】
nd 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. Versus PHP PHP (a recursive acronym for PHP: Hypertext Preprocessor) is a free, opensource, HTMLembedded 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 working, database access, distributed objects, and the like, whereas PHP requires learning an entirely new, less widely used language. A second advantage is that JSP is much more widely supported by tool and server vendors than is PHP. Versus Pure Servlets 畢業(yè)設(shè)計(jì)外文翻譯 12 JSP doesn39。t, in principle, be acplished with servlets. In fact, JSP documents are automatically translated into servlets behind the 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 experts 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 fet about servlets? Absolutely not! JSP developers need to know servlets for four reasons: 1. JSP pages get translated into servlets. You can39。t write that code if you don39。 it is a plementary one. It is also possible to use JavaScript on the server, most notably on Sun ONE (formerly iPla), 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 controlled by a munity that draws from many different panies. So, the technology can 畢業(yè)設(shè)計(jì)外文翻譯 13 incorporate improvements in successive releases. However, some groups have developed alternative Javabased technologies to try to address these deficiencies. This, in our judgment, is a mistake. Using a thirdparty tool like Apache Struts that augments JSP and servlet technology is a good idea when that tool adds sufficient benefit to pensate for the additional plexity. 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, 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 directory structure for Web applications and provide standard files (.war files) for deploying Web applications. All JSPpatible 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 application 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 expression language address two of the most wellfounded criticisms: the lack of good iteration constructs and the difficulty of accessing dynamic results without using either explicit Java code or verbose jsp:useBean elements. 3. Misconceptions About JSP Fetting JSP Is ServerSide Technology Here are some typical questions Marty has received (most of them repeatedly). ? Our server is running JDK . So, how do I put a Swing ponent in a JSP page? ? How do I put an image into a JSP page? I do not know the proper Java I/O mands to read image files. ? Since Tomcat does not support JavaScript, how do I make images that are highlighted when the user moves the mouse over them? ? Our clients use older 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 serverside process. But they do not. Thus: ? For putting applets with Swing ponents into Web pages, what matters is the browser39。s version is irrelevant. If the browser supports the Java 2 platform, you use the normal APPLET (or Java plugin) tag and would do so even if you were using nonJava technology on the server. 畢業(yè)設(shè)計(jì)外文翻譯 14 ? You do not need Java I/O to read image files。 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 patible with the browser, just as you would do with static HTML pages. ? And, of course you need not do anything to prevent clients from seeing JSP tags。s memory, initialized, and executed. But which step happens when? To answer that question, remember two points: ? The JSP page is translated into a servlet and piled only the first time it is accessed after having been modified. ? Loading into memory, initialization, and execution follow the normal rules for servlets. The most frequently misunderstood entries are highlighted. When referring to the table, note that servlets resulting from JSP pages use the _jspService method (called for both GET and POST requests), not doGet or doPost. Also, for initialization, they use the jspInit method, not the init page translated into servlet Servlet piled Servlet loaded into server3