【正文】
. 4. Some tasks are better acplished by a bination of servlets and JSP than by either servlets or JSP alone. Versus , which is pletely distinct from the Java programming language, is normally used to dynamically 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 fact, JSP can even be used to dynamically generate the JavaScript that will be sent to the client. So, JavaScript is not a peting technology。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 provide any capabilities that couldn39。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。 you aren39。 附 錄 Overview of JSP Technology JSP pages are translated into servlets. So, fundamentally, any task JSP pages can perform couldalso be acplished 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 puter 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: 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. You can use standard Website development tools. Even HTML tools that know nothing about JSP can be used because they simply ignore the JSP can divide up your development team. The Java programmers can work on the dynamic code. 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 plexity of your project, you can enforce a weaker or stronger separation between the static HTML and the dynamic content. Now, this discussion 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 bine them with the MVC architecture . You want the appropriate tool for the job, and servlets, by themselves, do not plete your toolkit. Advantages of JSP ,Over Competing TechnologiesA number of years ago, Marty was invited to attend a small 20person industry roundtable discussion on software technology. Sittin