【正文】
intenance and modification will also cause difficulties. In fact, CSDN the JSP / Servlet forum, can often see some questions, the code is very long, can logic is not very clear, a large number of HTML and Java code mixed together. This is the random development of the defects. Early dynamic pages mainly CGI (Common Gateway Interface, public Gateway Interface) technology, you can use different languages of the CGI programs, such as VB, C / C + + or Delphi, and so on. Though the technology of CGI is developed and powerful, because of difficulties in programming, and low efficiency, modify plex shortings, 2 it is gradually being replaced by the trend. Of all the new technology, JSP / Servlet with more efficient and easy to program, more powerful, more secure and has a good portability, they have been many people believe that the future is the most dynamic site of the future development of technology. Similar to CGI, Servlet support request / response model. When a customer submit a request to the server, the server presented the request Servlet, Servlet responsible for handling requests and generate a response, and then gave the server, and then from the server sent to the customer. And the CGI is different, Servlet not generate a new process, but with HTTP Server at the same process. It threads through the use of technology, reduce the server costs. Servlet handling of the request process is this: When received from the client39。s suitable for most servlets, and the DELETE and PUT HTTP methods are rarely used in a web application. It39。s look at the main requirements and see how we can map them to appropriate ponent types: ? Database access should be abstracted, to avoid knowledge of a specific data schema or database engine in more than one part of the application: beans in the role of Model can be used to acplish this. ? The database access beans must be made available to all other parts of the application when it starts: an application lifecycle event listener is the perfect ponent type for this task. ? Only authenticated users must be allowed to use the application: a filter can perform access control to satisfy this requirement. ? Request processing is best done with Java code: a servlet, acting as the Controller, fits the bill. ? It must be easy to change the presentation: this is where JSP shines, acting as the 10 View. Adding servlets, listeners, and filters to the mix minimizes the need for plex logic in the JSP pages. Placing all this code in Java classes instead makes it possible to use a regular Java piler and debugger to fix potential problems. Centralized Request Processing Using a Servlet With a servlet as the mon entry point for all application requests, you gain control over the page flow of the application. The servlet can decide which type of response to generate depending on the oute of the requested action, such as returning a mon error page for all requests that fail, or different responses depending on the type of client making the request. With the help from some utility classes, it can also provide services such as input validation, I18N preparations, and in general, encourage a more streamlined approach to request handling. When you use a servlet as a Controller, you must deal with the following basic requirements: ? All requests for processing must be passed to the single Controller servlet. ? The servlet must be able to distinguish requests for different types of processing. Here are other features you will want support for, even though they may not be requirements for all applications: ? A strategy for extending the application to support new types of processing requests in a flexible manner. 11 ? A mechanism for changing the page flow of the application without modifying code. Mapping Application Requests to the Servlet The first requirement for using a Controller servlet is that all requests must pass through it. This can be satisfied in many ways. If you have played around a bit with servlets previously, you39。 早期的動態(tài)網(wǎng)頁主要采用 CGI( Common Gateway Interface,公共網(wǎng)關(guān)接口)技術(shù),你可以使用不同的語言編寫 CGI程序,如 VB、 C/C++或 Delphi 等。 沈陽航空 航天大學 北方科技學院畢業(yè)設(shè)計 (外文翻譯 ) 13 別看這么復(fù)雜,其實簡單說來 Ser