【正文】
gned technology from Microsoft. is the part that directly petes with servlets and JSP. The advantages of JSP are twofold. First, JSP is portable to multiple operating systems and Web servers。 you aren39。t locked into deploying on Windows and IIS. Although the core .NET platform runs on a few nonWindows platforms, the ASP part does not. You cannot expect to deploy serious 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 .NET39。s C language 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 is written in Java, not VBScript or another ASPspecific language, so JSP is more powerful and better suited to plex applications that require reusable ponents. You could make the same argument when paring JSP to the previous version of ColdFusion。 with JSP you can use Java for the real code and 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 JSP doesn39。t provide any capabilities that couldn39。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 forget about servlets? Absolutely not! JSP developers need to know servlets for four reasons: 1. JSP pages get translated into servlets. You can39。t understand how JSP works without understanding servlets. 2. JSP consists of static HTML, specialpurpose JSP tags, and Java code. What kind of Java code? Servlet code! You can39。t write that code if you don39。t understand servlet programming. 3. Some tasks are better acplished 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 performing tasks (such as redirection) that involve little or no output. 4. Some tasks are better acplished by a bination of servlets and JSP than by either servlets or JSP alone. Versus JavaScript JavaScript, which is pletely distinct from the Java programming language, is normally used to dynamically gen