外文翻译--mysql和jsp的web应用程序-jsp程序(编辑修改稿)内容摘要:

than it is a Java engine that understands the Web. JSP grew out of Java servlets. Servlets allow the developer to handle the ining Web requests using a Java program that has access to all the normal information that a Common Gateway Interface (CGI) program would. In addition, the servlet has access to sessionpersistent objects. These are Java objects that are associated with a specific user session and can be used to store state between requests. Servlet programming was a major step forward in allowing developers to write wellstructured modular Web applications using an objectoriented language. It also solved the problem of state persistence, allowing more information to reside on the server during a transaction and less to have to pass back and forth between the user and the server. Servlets still suffered from one major problem. Because they eventually need to spit out HTML, the HTML coding had to be embedded in the servlet code. This led to code fragments like the one shown here: (HTML\nHEAD\nTITLEThank you for Registering/TITLE/HEAD\n)。 (IMG SRC=\\ WIDTH=200 HEIGHT=100 ALIGN=\LEFT\”)。 This kind of embedding gets very old very fast when you have to code a lot of pages. In addition, having to escape all of the quotation marks can lead to a lot of confusing and hardtofind errors if you leave out a backslash. Eventually, a stillbetter idea emerged. Suppose that you could bine the best of static HTML pages and with the interactive capabilities of servlets. The result was JavaServer Pages (on the Microsoft side, the result was Active Server Pages). As Figure shows, JSP is a plicated beast. In the next chapter, you39。 ll walk through this flow in detail, but for the moment, here are the major steps: 1. A request es in from a browser using the normal HTTP request format. 2. The Web server hands off the request to JSP. JSP looks at the filename and finds the appropriate JSP file. 3. The .jsp file is converted into a .java file, containing Java code that will create a class whose name is derived from the .jsp filename. 4. JSP then piles the .java file using javac to produce a .class file. Note that the two previous steps are skipped if a .class file already exists and is newer than the .jsp file. 5. An instance of the newly created class is instantiated and sent the _jspService message. 6. The new instance looks to see if there is already an instance of the object called user existing in the session object space for the currently connected user. If not, one is instantiated. 7. As part of servicing , the user instance is called with the getUserName() method. 8. If the JSP processing requires access to information in a database, it uses JDBC to make the connection and handle the SQL requests. As you can see, a tremendous amount of power is available in the JSP world. Developers are free to write Web pages that look mostly like HTML, except where callouts to Java are required. But, at the same time, they are free to develop fully fleshedout objectoriented applications using all the features that Java can bring to bear. They also get all the benefits of servlets, including session persistence. Why Do We Need Databases? Well, one reason is so that Larry Ellison of Oracle can afford to keep himself on Prozac when he thinks about Bill Gates. A more serious answer is the same reason that drove man to first press a stick against a piece of wet mud: because it39。 s good to write things down. Web servers are marvelous creatures, but。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。