JSP技术外文文献 jsp技术的特点
外文文献 JSP Technology and Servlets JSP profile JSP (JavaServer Pages) is initiated by Sun Microsystems, Inc., with many companies to participate in the establishment of a dynamic web page technical standards. JSP technology somewhat similar to ASP technology, it is in the traditional HTML web page document (*. htm, *. html) to insert the Java programming paragraph (Scriptlet) and JSP tag (tag), thus JSP documents (*. jsp). Using JSP development of the Web application is cross that can run on Linux, is also available for other operating systems. JSP technology to use the Java programming language prepared by the category of XML tags and scriptlets, to produce dynamic pages package processing logic. Page also visit by tags and scriptlets exist in the services side of the resources of logic. JSP page logic and web page design and display separation, support reusable component-based design, Web-based application development is rapid and easy. Web server in the face of visits JSP page request, the first implementation of the procedures of, and then together with the results of the implementation of JSP documents in HTML code with the return to the customer. Insert the Java programming operation of the database can be reoriented websites, in order to achieve the establishment of dynamic pages needed to function.JSP and Java Servlet, is in the implementation of the server, usually returned to the client is an HTML text, as long as the client browser will be able to visit. JSP 1.0 specification of the final version is launched in September 1999, December has introduced 1.1 specifications. At present relatively new is JSP1.2 norms, JSP2.0 norms of the draft has also been introduced.JSP pages from HTML code and Java code embedded in one of the components. JS script language synopsis JS is javascrip, Javascript is one kind the script language which comes by the Netscape LiveScript development, the main purpose is to solve the server terminal language, for instance Perl, carry-over speed question. At that time served the end to need to carry on the confirmation to the data, because the network speed was quite slow, only then 28.8kbps, the confirmation step waste's time were too many. Therefore Netscape browser Navigator has joined Javascript, has provided the data confirmation basic function. The JavaScript official name is “ECMAScript”. This standard by ECMA organization development and maintenance. ECMA262 is the official JavaScript standard. This standard based on JavaScript (Netscape) and JScript (Microsoft). Netscape (Navigator 2.0) Brendan Eich has invented this language, started from 1996, already appeared in all Netscape and in the Microsoft browser. The ECMA262 development began in 1996, in 1997 July, the ECMA general meeting has accepted its first edition. The script uses one specific descriptive language, rests on certain form compilation to be possible the execution document, is also called as great or the batch run document. The script usually may transfer temporarily by the application procedure and carry out. Each kind of script present widely is applied in the homepage design, because the script not only may reduce the homepage the scale and raises the homepage browsing speed, moreover may enrich the homepage performance, like animation, sound and so on. Cites a most common example, when we click in the homepage the Email address can transfer Outlook Express or the Foxmail this kind of mail software automatically, is realizes through the script function. Also because of script these characteristics, the human who harbors ulterior motives by some are often using. For example joins some destruction computer system's order in the script, like this works as the user browsing homepage, once transfers this kind of script, will then cause the user the system to come under the attack. Therefore the user should act according to visits homepage the trust degree selective security rank, specially regarding these itself content on the illegal homepage, do not permit the use script easily. Through “the safe establishment” the dialog box, the choice “the script” under option each kind of establishment may with ease realize to script being forbid and begins using. JSP and Servlets The technology of JSP and Servlet is the most important technology which use Java technology to exploit request of server, and it is also the standard which exploit business application .Java developers prefer to use it for a variety of reasons, one of which is already familiar with the Java language for the development of this technology are easy to learn Java to the other is “a preparation, run everywhere“ to bring the concept of Web applications, To achieve a “one-prepared everywhere realized.“ And more importantly, if followed some of the principles of good design, it can be said of separating and content to create high-quality, reusable, easy to maintain and modify the application. For example, if the document in HTML embedded Java code too much (script), will lead the developed application is extremely complex, difficult to read, it is not easy reuse, but also for future maintenance 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 complex shortcomings, 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 client's request, calling service methods, the method of Servlet arrival of the first judgement is what type of request (GET / POST / HEAD…), then calls the appropriate treatment (DoGet / doPost / doHead…) and generate a response. Although such a complex, in fact, simply said to Servlet is a Java class. And the general category of the difference is that this type operating in a Servlet container, which can provide session management and targeted lifecycle management. So that when you use the Servlet, you can get all the benefits of the Java platform, including the safety of the management, use JDBC access the database and crossplatform capability. Moreover, Servlet using thread, and can develop more efficient Web applications. JSP technology is a key J2EE technology, it at a higher level of abstraction of a Servlet. It allows conventional static and dynamic HTML content generated by combining an HTML page looks like, but as a Servlet to run. There are many commercial application server support JSP technology, such as BEA WebLogic, IBM WebSphere, JRun, and so on. JSP and Servlet use more than simple. If you have a JSP support for Web servers, and a JSP document, you can put it Fangdao any static HTML files can be placed, do not have to compile, do not have to pack, do not have to ClassPath settings, you can visit as ordinary Web It did visit, the server will automatically help you to do other work. JSP document looks like an ordinary static HTML document, but inside contains a number of Java code. It uses. Jsp the suffix, used to tell the server this document in need of special treatment. When we visit a JSP page, the document will first be translated into a JSP engine Java source files, is actually a Servlet, and compiler, and then, like other Servlet, from Servlet engine to handle. Servlet engine of this type loading, handling requests from customers, and the results returned to the customer. After another visit this page to the customer, as long as the paper there have been no changes, JSP engine has been loaded directly call the Servlet. If you have already been modified, it will be once again the implementation of the above process, translate, compile and load. In fact, this is the so-called “first person to punishment.“ Because when the first visit to the implementation of a series of the above process, so will spend some time after such a visit would not. Java servlets offer a powerful API that provides access to all the information about the request, the session, and the application. combining JSP with servlets lets you clearly separate the application logic from the presentation of the application; in other words, it lets you use the most appropriate component type for the roles of Model, View and Controller. Servlets, Filters, and Listeners A servlet is a Java class that extends a server with functionality for processing a request and producing a response. It's implemented using the classes and interfaces defined by the Servlet API. The API consists of two packages: the javax.servlet package contains classes and interfaces that are protocolindependent, while the javax.servlet.http package provides HTTP-specific extensions and utility classes. What makes a servlet a servlet is that the class implements an interface named javax.servlet.Servlet, either directly or by extending one of the support classes. This interface defines the methods used by the web container to manage and interact with the servlet. A servlet for processing HTTP requests typically extends the javax.servlet.http.HttpServlet class. This class implements the Servlet interface and provides additional methods suitable for HTTP processing. Servlet Lifecycle The web container manages all aspects of the servlet's lifecycle. It creates an instance of the servlet class when needed, passes requests to the instance for processing, and eventually removes the instance. For an HttpServlet, the container calls the following methods at the appropriate times in the servlet lifecycle. Besides the doGet( ) and doPost( ) methods, there are methods corresponding to the other HTTP methods: doDelete( ), doHead( ), doOptions( ), doPut( ), and doTrace( ). Typically you don't implement these methods; the HttpServlet class already takes care of HEAD, OPTIONS, and TRACE requests in a way that's suitable for most servlets, and the DELETE and PUT HTTP methods are rarely used in a web application. It's important to realize that the container creates only one instance of each servlet. This means that the servlet must be thread safe - able to handle multiple requests at the same time, each executing as a separate thread through the servlet code. Without getting lost in details, you satisfy this requirement with regards to instance variables if you modify the referenced objects only in the init( ) and destroy( ) methods, and just read them in the request processing methods. Compiling and Installing a Servlet To compile a servlet, you must first ensure that you have the JAR file containing all Servlet API classes in the CLASSPATH environment variable. The JAR file is distributed with all web containers. Tomcat includes it in a file called servlet.jar, located in the common/lib directory. On a Windows platform, you include the JAR file in the CLASSPATH. Reading a Request One of the arguments passed to the doGet( ) and doPost( ) methods is an object that implements the HttpServletRequest interface. This interface defines methods that provide access to a wealth of information about the request. Generating a Response Besides the request object, the container passes an object that implements the HttpServletResponse interface as an argument to the doGet( ) and doPost( ) methods. This interface defines methods for getting a writer or stream for the response body. It also defines methods for setting the response status code and headers. Using Filters and Listeners The servlet specification defines two component types beside servlets: filters and listeners. These two types were introduced in the Servlet 2.3 specification, so if you're using a container that doesn't yet support this version of the specification, I'm afraid you're out of luck. Filters A filter is a component that can intercept a request targeted for a servlet, JSP page, or static page, as well as the response before it's sent to the client. This makes it easy to centralize tasks that apply to all requests, such as access control, logging, and charging for the content or the services offered by the application. A filter has full access to the body and headers of the request and response, so it can also perform various transformations. One example is compressing the response body if the Acceptlanguage request header indicates that the client can handle a compressed response. A filter can be applied to either a specific servlet or to all requests matching a URL pattern, such as URLs starting with the same path elements or having the same extension. Listeners Listeners allow your application to react to certain events. Prior to Servlet 2.3, you could handle only session attribute binding events (triggered when an object was added or removed from a session). You could do this by letting the object saved as a sessionattributimplement the HttpSessionBindingListener interface. With the new interfaces introduced in the 2.3 version of the specification, you can create listeners for servlet context and session lifecycle events as well as session activation and passivation events (used by a container that temporarily saves session state to disk or migrates a session to another server). A newsession attribute event listener also makes it possible to deal with attribute binding events for all sessions in one place, instead of placing individual listener objects in each session. The new types of listeners follow the standard Java event model. In other words, a listener is a class that implements one or more of the listener interfaces. The interfaces define methods that correspond to events. The listener class is registered with the container when the application starts, and the container then calls the event methods at the appropriate times. Initializing Shared Resources Using a Listener Beans like this typically need to be initialized before they can be used. For instance, they may need a reference to a database or some other external data source and may create an initial information cache in memory to provide fast access even to the first request for data. You can include code for initialization of the shared resources in the servlet and JSP pages that need them, but a more modular approach is to place all this code in one place and let the other parts of the application work on the assumption that the resources are already initialized and available. An application lifecycle listener is a perfect tool for this type of resource initialization. This type of listener implements the javax.servlet.ServletContextListener interface, with methods called by the container when the application starts and when it shuts down. Picking the Right Component Type for Each Task The Project Billboard application introduced is a fairly complex application. Half the pages are pure controller and business logic processing, it accesses a database to authenticate users, and most pages require access control. In real life, it would likely contain even more pages, for instance, pages for access to a shared document archive, time schedules, and a set of pages for administration. As the application evolves, it may become hard to maintain as a pure JSP application. It's easy to forget to include the access control code in new pages. This is clearly an application that can benefit from using a combination of JSP pages and the component types defined by the servlet specification for the MVC roles. Let's look at the main requirements and see how we can map them to appropriate component 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 accomplish 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 component 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 View. Adding servlets, listeners, and filters to the mix minimizes the need for complex logic in the JSP pages. Placing all this code in Java classes instead makes it possible to use a regular Java compiler and debugger to fix potential problems. Centralized Request Processing Using a Servlet With a servlet as the common 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 outcome of the requested action, such as returning a common 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. 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, you're probably used to invoking a servlet with a URI that starts with /myApp/servlet. This is a convention introduced by Suns Java Web Server (JWS), the first product to support servlets before the API was standardized. Most servlet containers support this convention today, even though it's not formally defined in the servlet specification. 中文翻译 JSP技术和Servlets JSP简介 JSP(JavaServer Pages)是由Sun Microsystems公司倡导、许多公司参与一起建立的一种动态网页技术标准。JSP技术有点类似ASP技术,它是在传统的网页HTML文件(*.htm,*.html)中插入Java程序段(Scriptlet)和JSP标记(tag),从而形成JSP文件(*.jsp)。用JSP开发的Web应用是跨平台的,即能在Linux下运行,也能在其他操作系统上运行。
JSP技术使用Java编程语言编写类XML的tags和scriptlets,来封装产生动态网页的处理逻辑。网页还能通过tags和scriptlets访问存在于服务端的资源的应用逻辑。JSP将网页逻辑与网页设计和显示分离,支持可重用的基于组 件的设计,使基于Web的应用程序的开发变得迅速和容易。
Web服务器在遇到访问JSP网页的请求时,首先执行其中的程序段,然后将执行结果连同JSP文件中的HTML代码一起返回给客户。插入的Java程序段可以操作数据库、重新定向网页等,以实现建立动态网页所需要的功能。JSP与Java Servlet一样,是在服务器端进行执行的,通常返回该客户端的就是一个HTML文本,因此客户端只要有浏览器就能浏览。
JSP的1.0规范的最后版本是1999年9月推出的,12月又推出了1.1规范。目前较新的是JSP1.2规范,JSP2.0规范的征求意见稿也已出台。JSP页面由HTML代码和嵌入其中的Java代码所组成。
JS脚本语言简介 JS即javascrip,Javascript是一种由Netscape的LiveScript发展而来的脚本语言,主要目的是为了解决服务器终端语言,比如Perl,遗留的速度问题。当时服务端需要对数据进行验证,由于网络速度相当缓慢,只有28.8kbps,验证步骤浪费的时间太多。于是Netscape的浏览器Navigator加入了Javascript,提供了数据验证的基本功能。 JavaScript 的正式名称是 “ECMAScript“。这个标准由 ECMA 组织发展和维护。ECMA-262 是正式的 JavaScript 标准。这个标准基于JavaScript和 JScript。Netscape (Navigator 2.0) 的 Brendan Eich 发明了这门语言,从 1996 年开始,已经出现在所有的 Netscape 和 Microsoft 浏览器中。ECMA-262 的开发始于 1996 年,在 1997 年 7 月,ECMA 会员大会采纳了它的首个版本。
脚本script是使用一种特定的描述性语言,依据一定的格式编写的可执行文件,又称作宏或批处理文件。脚本通常可以由应用程序临时调用并执行。各类脚本目前被广泛地应用于网页设计中,因为脚本不仅可以减小网页的规模和提高网页浏览速度,而且可以丰富网页的表现,如动画、声音等。举个最常见的例子,当我们点击网页上的E-mail地址时能自动调用Outlook Express或Foxmail这类邮件软件,就是通过脚本功能来实现的。也正因为脚本的这些特点,往往被一些别有用心的人所利用。例如在脚本中加入一些破坏计算机系统的命令,这样当用户浏览网页时,一旦调用这类脚本,便会使用户的系统受到攻击。所以用户应根据对所访问网页的信任程度选择安全等级,特别是对于那些本身内容就非法的网页,更不要轻易允许使用脚本。通过“安全设置”对话框,选择“脚本”选项下的各种设置就可以轻松实现对脚本的禁用和启用。
Servlet和JSP Servlet和JSP技术是用Java开发服务器端应用的主要技术,是开发商务应用表示端的标准。Java开发者喜欢使用它有多种原因,其一是对于已经熟悉Java语言的开发者来说这个技术容易学习;
其二是Java把“一次编写,到处运行”的理念带入到Web应用中,实现了“一次编写,到处实现”。而且更为重要的是,如果遵循一些良好的设计原则的话,就可以把表示和内容相分离,创造出高质量的、可以复用的、易于维护和修改的应用程序。比方说,在HTML文档中如果嵌入过多的Java代码(scriptlet),就会导致开发出来的应用非常复杂、难以阅读、不容易复用,而且对以后的维护和修改也会造成困难。事实上,在CSDN的JSP/Servlet论坛中,经常可以看到一些提问,代码很长,可以逻辑却不是很清晰,大量的HTML和Java代码混杂在一起,让人看得一头雾水。这就是随意开发的弊端。
早期的动态网页主要采用CGI(Common Gateway Interface,公共网关接口)技术,你可以使用不同的语言编写CGI程序,如VB、C/C++或Delphi等。虽然CGI技术发展成熟且功能强大,但由于编程困难、效率低下、修改复杂等缺点,所以有逐渐被取代的趋势。在所有的新技术中,JSP/Servlet具备更高效、更容易编程、功能更强、更安全和具有良好的可移植性,因而被许多人认为是未来最有发展前途的动态网站技术。 与CGI相似,Servlet支持请求/响应模型。当一个客户向服务器递交一个请求时,服务器把请求送给Servlet,Servlet负责处理请求并生成响应,然后送给服务器,再由服务器发送给客户。与CGI不同的是,Servlet没有生成新的进程,而是与HTTP Server处于同一进程中。它通过使用线程技术,减小了服务器的开销。Servlet处理请求的过程是这样的:当收到来自客户端的请求后,调用service方法,该方法中Servlet先判断到来的请求是什么类型的(GET/POST/HEAD„),然后调用相应的处理方法(doGet/doPost/doHead„)并生成响应。 别看这么复杂,其实简单说来Servlet就是一个Java类。与一般类的不同之处是,这个类运行在一个Servlet容器内,可以提供session管理和对象生命周期管理。因而当你使用Servlet的时候,你可以得到Java平台的所有好处,包括安全性管理、使用JDBC访问数据库以及跨平台的能力。而且,Servlet使用线程,因而可以开发出效率更高的Web应用。
JSP技术是J2EE的一个关键技术,它在更高一级的层次上抽象Servlet。它可以让常规静态HTML与动态产生的内容相结合,看起来像一个HTML网页,却作为Servlet来运行。现在有许多商业应用服务器支持JSP技术,比如BEA WebLogic、IBM WebSphere、 JRun等等。使用JSP比用Servlet更简单。如果你有一个支持JSP的Web服务器,并且有一个JSP文件,你可以把它放倒任何静态HTML文件可以放置的位置,不用编译,不用打包,也不用进行ClassPath的设置,就可以像访问普通网页那样访问它,服务器会自动帮你做好其他的工作。 JSP 文件看起来就像一个普通静态HTML文件,只不过里面包含了一些Java代码。它使用.jsp的后缀,用来告诉服务器这个文件需要特殊的处理。当我们访问一个JSP页面的时候,这个文件首先会被JSP引擎翻译为一个Java源文件,其实就是一个Servlet,并进行编译,然后像其他Servlet一样,由Servlet引擎来处理。Servlet引擎装载这个类,处理来自客户的请求,并把结果返回给客户。
以后再有客户访问这个页面的时候,只要该文件没有发生过更改,JSP引擎就直接调用已经装载的Servlet。如果已经做过修改的话,那就会再次执行以上过程,翻译、编译并装载。其实这就是所谓的“第一人惩罚”。因为首次访问的时候要执行一系列以上的过程,所以会耗费一些时间;
以后的访问就不会这样了。 Java servlet提供了一种强有力的API,用这个API可以访问关于请求、会话和应用程序的所有信息。将servlet和JSP页面组合起来使用,可以把应用程序的逻辑部分和外观呈现部分清楚地分开;
换句话,利用这个方式可以对模型、视图和控制器这三种角色分别使用最合适的组件类型。
Servlet、过滤器和监听器 Servlet是一种Java类,它使得服务器的功能可扩展至处理请求和生成应答。它是用Servlet API定义的类和接口实现的。API由两个程序包组成:jvavax.servlet程序包包含独立于协议的类和接口,而javax.servlet.http程序包则提供HTTP特定的扩展的实用程序类。 Servlet的实质是实现了接口javax.servlet.Servlet的类,实现是直接完成或通过扩展某个支持类来完成的。该接口定义了Web容器用来管理servlet和与之交互的方法。用于处理HTTP请求的servlet一般情况下都会扩展javax.servlet.http.HttpServlet类。该类实现了Servlet接口,并提供了使用HTTP处理的附加方法。
Servlet的生命周期 Web容器管理servlet生命周期的所有方面。它根据需要创建servlet类的实例、将请求传递给实例进行处理,最终删除实例。对于HttpServlet来说,容器会在servlet生命周期的适当时间调用方法。 除了doGet()和doPost()方法之外,还有一些对应于其他HTTP方法的方法:doDelete()、doHead()、doOptiongs()、doPut()和doTrace()。一般情况下不用实现这些方法,因为HttpServlet类已经用适用于大多数servlet的方法考虑到了HEAD、OPTIONS和TRACE请求,而且DELETE和PUT这两种HTTP方法很少用在Web应用程序中。
容器只为每个Servlet创建一个实例非常重要。这意味着servlet必须是线程安全的—即,能够同时处理多个请求,每个处理都通过servlet代码作为单独的线程来执行。如果只在init()和destroy()方法中修改参考的对象,而且只在请求处理方法中读取他们,那么不用丧失任何细节就可以满足关于实例变量的这个要求。
编译和安装servlet 要编译servlet,必须首先确保JAR文件包含着CLASSPATH环境变量中所有Servlet API类。该JAR文件将随所有的Web容器一起发布。Tomcat中包含了一个名为servlet.jar的JAR文件,位于common/lib目录中。在Windows平台中,应在CLASSPATH中包含JAR文件。 读取请求 传递到doGet()和doPost()方法的参数之一是实现了HttpServletRequest接口的对象。该接口定义的方法可提供对关于请求的许多信息的访问。
生成应答 除应答对象之外,容器还将实现HttpServletRequest接口的对象作为icanshu传递给doGet()和doPost()方法。该接口定义了为应答行为体获取数序程序或流的方法。它还定义了设置应答状态代码和首部的方法。 使用过滤器和监听器 Servlet规范servlet内定义了两种组件类型:过滤器和监听器。这两种类型是在Servlet 2.3规范中引入的,因此,如果你使用的是不支持该版本规范的容器,恐怕就不能继续学习了。 过滤器 过滤器是一种组件,可以解释对servlet、JSP页面或静态页面的请求以及发送给客户端之前的应答。这样可以很容易地将应用于所有请求的任务集中在一起,例如访问控制、登录和内容的开销或应用提供的服务等。过滤器对请求与应答的行为体和首部具有完全访问权限,因此还可以执行各种转换。例如,如果Accept-Language请求首部指出客户端可以处理压缩的应答,那么过滤器就可以压缩应答的行为体。 过滤器可以应用在特定servlet上,或匹配某种URL模式的所有请求上,例如以相同的路径元素开头或具有相同扩展名的URL。
监听器 监听器允许应用程序对特定事件做出回应。Servlet 2.3之前,只能处理会话属性绑定事件(在添加对象或从会话中删除对象时)。实现监听器的方式是用保存为会话属性(使用HttpSession.setAttribute()方法)的对象实现HttpSessionBinding-Listener接口。随着Servlet规范的2.3版本中新接口的引入,可以为servlet环境和会话生命周期事件以及激活和钝化事件(容器用来暂时将会话状态保存在磁盘上或将会话移植到另一个服务器上)创建监听器。使用新的会话属性事件监听器还可以在一个位置上处理所有会话的属性绑定事件,而不是在每个会话中防止单独的监听器对象。 新类型的监听器遵循的是标准Java事件模型。换句话说,监听器是实现了一个或多个监听器接口的类。接口定义的是事件相应的方法。当应用程序启动是,容易会注册监听器类,然后该容器会在合适的事件调用那些事件方法。
使用监听器初始化共享资源 Bean一般都有需要在使用之前进行初始化。例如,它们可能需要对数据库或某些其他外部数据源的引用,还可能在内存中创建一个初始消息缓存,以便即使是第一个请求数据也可以提供更快的访问。可以在需要共享资源的servlet和JSP页面中包含初始化共享资源的代码,但是更标准的方法是在一个位置放置所有这些代码,并在假设资源已经初始化和可用的情况下,使应用程序的其他部分可以正常工作。应用程序生命周期监听器是此类资源初始化的绝好工具。此类监听器实现了javax.servlet.ServletContextListener接口,当应用程序启动和关闭时会由容器调用该接口的方法。 为每个任务选择正确的组件类型 在之前介绍的项目公告牌应用程序是相当复杂的应用程序。页面的一般都是纯粹的控制器和商务逻辑处理,它访问数据库以对用户进行身份验证,而且多数页面都需要访问控制。在现实生活中,它可能会包含更多的页面,例如,用于访问共享文档档案、事件表的页面和用于管理的一组页面等。由于应用程序在不断地发展变化,因此可能变得很难作为纯JSP应用程序来维护。例如,很容易忘记在新页面中包含访问控制代码。 很明显,这种应用程序可以从使用JSP页面与组件类型的组合中受益,其中组件类型由用于MVC角色的servlet规范所定义。下面看一下主要的要求,并了解如何将他们映射到适当的组件类型上:
(1) 数据库访问应该是抽象的,从而避免连接应用程序中多个部分的特定数据模式或数据库引擎:模型角色中的bean可以用来完成这种认知。
(2) 数据库访问bean必须在应用程序启动时可用于所有其他的部分:应用程序生命周期时间监听器是用了该任务的完美的组件类型。
(3) 只有通过验证的用户才允许使用应用程序:过滤器可以完成访问控制以满足该要求。
(4) 用Java代码进行请求处理效果最佳:servlet作为控制器正符合需要。
(5) 必须很容易改编外观呈现:这正是JSP的反光点,也就是作为视图。
将servlet、监听器和过滤器混合起来,就将JSP页面对复杂逻辑的需求降到了最低。将这些代码放置到Java类中后,就可以使用普通的Java编译程序和调试程序来修复潜在的问题。
使用servlet集中处理请求 将servlet作为所有应用程序请求的公共入口时,可以获得对应用程序页面流的整体控制。Servlet可以根据所请求行为的结果来决定要生成的应答类型,例如,为所有失败的请求返回公共的错误页面,或者根据发出请求的客户端返回不同的应答等。在某些使用程序类的帮助下,servlet还可以提供诸如输入验证、J18N准备之类的服务,而且通常会鼓励使用更有效率的方法来请求处理。
将应用程序请求映射到servlet 使用控制器servlet的第一个要求是所有请求必须都经过该servlet。该要求可以通过多种方式来满足。如果你以前曾经使用过servlet,那么你可能习惯于用以/myApp/servlet开头的URI来调用servlet。这是由Sun公司的Java Web Server(JWS)所引入的一个约定,JWS是在推出标准API之前第一个支持servlet的产品。今天,大部分servlet容器都支持这个约定,即使servlet规范中并没有正式的定义。
相关热词搜索:外文 文献 技术 JSP技术外文文献 jsp技术的特点 jsp是一种什么技术
- 范文大全
- 说说大全
- 学习资料
- 语录
- 生肖
- 解梦
- 十二星座
-
2022年4月主题党日活动记录范文15篇
2022年4月主题党日活动记录范文15篇2022年4月主题党日活动记录范文篇1一个崇尚阅读的民族,必然精神饱满、意气风发、活力四射。习近平总书记强调:“学习
【活动总结】 日期:2022-08-01
-
少先队的光荣历史故事 队前教育-光辉历程
2017-2018学年队前教育1光辉历程一、劳动童子团1924——1927二、三十年代年的中国是一个
【法律文书】 日期:2020-06-23
-
家乡赋|最美的家乡赋
家乡赋 孙传志 今安康市,白河双丰镇,吾之家乡也。三环沃土,山水环抱。其北依山,山系五岭,山
【调研报告】 日期:2020-04-01
-
党支部1-12月全年主题党日活动计划表
2022年党支部主题党日活动计划表序号活动时间活动方式活动内容12022年1月专题学习研讨集中观看2022年新年贺词,积极开展学习研讨交流。组织生活会组织党员认真对照党章...
【活动总结】 日期:2022-10-14
-
【人教版1-6年级数学上册知识点精编】1-6年级数学人教版教材
人教版二年级数学上册知识点汇总第一单元长度单位一、米和厘米1、测量物体的长度时,要用统一的标准去测量
【调研报告】 日期:2020-11-08
-
2022年2月份主题党日活动记录5篇
2022年2月份主题党日活动记录5篇2022年2月份主题党日活动记录篇1尊敬的党组织:在今年的开学初,本人积极参加教研室组织的教研活动,在学校教研员的指
【活动总结】 日期:2022-08-12
-
2023年平安校园建设方案13篇
平安校园建设方案“平安校园”创建工作,我们幼儿园全体教职员工一直把它当作头等大事来抓。领导高度重视,以“平安校园”创建活动为抓手,建立和规范校园安全工作机制
【规章制度】 日期:2023-11-02
-
医院最佳主题党日活动11篇
医院最佳主题党日活动11篇医院最佳主题党日活动篇1 医院最佳主题党日活动篇2为隆重纪念中国共产党成立100周年,进一步巩固党的群众路线教育实践活动成果,切实
【活动总结】 日期:2022-10-29
-
南京大屠杀国家公祭日悼念文案句子11篇
南京大屠杀国家公祭日悼念文案精选句子1、惟有民魂是值得宝贵的,惟有他发扬起来,中国才有真进步。——鲁迅2、我爱我的祖国,爱我的人民,离开了它,离开了他们,我
【企划文案】 日期:2023-10-20
-
主题党日活动记录202210篇
主题党日活动记录202210篇主题党日活动记录2022篇12021年是中国共产党成立100周年,为广泛开展爱国主义宣传教育,铭记党的历史,讴歌党的光辉历程,
【活动总结】 日期:2022-08-02
-
入少先队员改正的缺点有哪些_少先队申请书
敬爱的少先队组织:我们是共产主义接班人,继承革命先辈的光荣传统,爱祖国,爱人民,鲜艳的红领巾飘扬在前胸 我叫xx,是一年级(x)班的小学生。每当听到这首...
【简历资料】 日期:2019-07-28
-
正式的晚宴邀请函 公司晚宴邀请函
尊敬的先生 女士: 我公司谨定于xxxx年xx月xx日xx:xx在xxxx店隆重举行xx市xx届xxxx晚宴(宴会地址:xx区xx路xxxx) 敬请届时光临!xxxxxx集团股份有限公司xxxx有限公司敬邀xxxx年xx月xx日
【简历资料】 日期:2019-08-03
-
一年级新学期目标简短_一年级学生新学期打算
新学期到了,我是一年级下册的小学生了。 上课的时候,我要认真学习,不做小动作,认真听讲。我要认真学习,天天向上,努力学习,耳朵要听老师讲课,眼睛要瞪得大大的看老...
【简历资料】 日期:2019-10-26
-
[信访复查复核制度作用探讨]信访复查复核有用吗
作为我国特有的一项制度,信访制度的出现并长期存在不是偶然的,虽然一些法学专家认为信访制度具有“人治”
【职场指南】 日期:2020-02-16
-
[党员干部2019年主题教育个人问题检视清单及整改措施2篇] 党员干部
2019年主题教育问题检视清单及整改措施根据主题教育领导小组办公室《关于认真做好主题教育检视问题整改
【求职简历】 日期:2019-11-08
-
网络维护工作内容_(精华)国家开放大学电大专科《网络系统管理与维护》形考任务1答案
国家开放大学电大专科《网络系统管理与维护》形考任务1答案形考任务1理解上网行为管理软件的功能【实训目
【职场指南】 日期:2020-07-17
-
党委会与局长办公会的区别_局长办公会制度
为进一步加强xxx局工作的规范化、制度化建设,提高行政效能,规范议事程序,特制定本制度。一、会议形式1、局长办公会议由局长、副局长参加。由局长召集和主持。根据工作需要...
【求职简历】 日期:2019-07-30
-
学生会组织部部长竞选稿5篇
学生会组织部部长竞选稿以“三制”为统领推进农村党的建设中共**市委组织部近年来,**市认真落实中央、省和徐州市委的部署,积极适应发展要求,从加强领导体制、运
【求职简历】 日期:2023-11-06
-
如何凝心聚力谋发展【坚定信心谋发展凝心聚力促跨越】
当前,清河正处于在苏北实现赶超跨越基础上全面腾飞的战略机遇期,处于在全市率先实现全面小康基础上率先实
【简历资料】 日期:2020-03-17
-
《铁拳砸碎“黑警伞”》警示教育片观后感
影片深刻剖析了广西北海市公安局海西派出所原所长张枭杰蜕变堕落的轨迹。观看警示教育片后,做为一名党员教
【简历资料】 日期:2020-08-17
-
2022年度区委书记在年轻干部村情调研动员会上的讲话提纲【优秀范文】
今天,xxx区年轻干部村情调研活动正式启动。这是区委加强年轻干部实践锻炼的重要举措,是推动乡村振兴先行示范区建设的有益探索,目的就是要为xxx的绿色转型、乡村振兴谋思路...
【其他范文】 日期:2022-11-04
-
[先进团支部主要事迹] 优秀团支部事迹1000字
一支部同学学习情况:我班同学学习优异努力刻苦,入学时成绩优异,其中丁浩同学入学分数为西工大山西考生第一名,荣获英才奖学金,而且姜凝同学更是以677分成为西工大陕西考生...
【汇报体会】 日期:2019-08-03
-
《庄子·天下》《论六家之要旨》《汉书·艺文志·道家略》论道家之异同
□刘雅楠“道家”一词最早出现于《史记·陈丞相世家》,司马谈的《论六家之要旨》首次将“道家”作为学派来
【其他范文】 日期:2023-04-07
-
xx年基层协会建设办公室工作总结
xx年基层协会建设办公室工作总结撰写人:___________日期:___________xx年基层
【导游词】 日期:2021-03-03
-
【保护黄河宣传标语】各类宣传标语搜集(全文)
当前位置:>>>2021-10-03篇一:我搜集一些宣传标语(一)公益宣传用语1.宣传普及靠大家,金融知识进万家2.心贴心的服务,手握手的承诺3.服务有起点,满意无终点(二)个人...
【其他范文】 日期:2022-09-23
-
医院党总支抓党建先锋杯汇报(1)
医院党总支抓党建先锋杯汇报(1) 各位领导:大家好!首先欢迎各位领导莅临我院检查指导工作。下面,我就
【评语寄语】 日期:2020-07-10
-
党员干部责任与担当的感悟10篇
【篇一】敢于担当是一种责任、一种精神,更是一种能力,是党员干部必须具备的基本素质。党的十八大以来,习
【毕业论文】 日期:2021-06-15
-
地税局人事处副处长在中心组理论学习会上的发言
根据省局机关党委“两学一做”专题学习教育活动安排,我通过对党章党规和习总书记系列讲话的认真学习,认识
【其他范文】 日期:2020-04-13
-
三句半【庆元宵(三句半)】
庆元宵敲锣打鼓庆元宵,热热闹闹兴致高,我们四人来表演,请看!到十五还有一两天,祝大家吉祥如意大团圆,我们给大家鞠个躬,拜年!今天是元宵联欢会,咱就说说咱地税,辛辛...
【礼仪】 日期:2019-08-24
-
党员思想状况调研分析报告
下面是小编为大家整理的党员思想状况调研分析报告文章,
【其他范文】 日期:2022-10-08
-
军转座谈会交流发言4篇
军转座谈会交流发言4篇军转座谈会交流发言篇1大家好,我叫贺丽,2015届选调生,来自康定市委组织部,现在省委编办跟班学习。今天,非常荣幸向大家汇报我的学习收
【发言稿】 日期:2022-10-27
-
12岁生日小寿星发言4篇
12岁生日小寿星发言4篇12岁生日小寿星发言篇1各位来宾、各位朋友:大家好!今天,我们欢聚在这里,共同庆祝**十二周岁生日。首先,我代表**的父母以
【发言稿】 日期:2022-07-31
-
廉政大会总结发言稿7篇
廉政大会总结发言稿7篇廉政大会总结发言稿篇1各位领导,同志们:根据会议安排,我就党风廉政建设工作做表态发言,不妥之处,请批评指正。一、提高认识,切实
【发言稿】 日期:2022-10-30
-
【企业疫情风险控制方案】 2020企业复工疫情方案
企业疫情风险控制方案2020新冠病毒肺炎疫情防控工作总结汇报3篇 关于新型冠状病毒感染的肺炎疫
【演讲稿】 日期:2020-02-27
-
我最敬佩的人开头_我敬佩的一个人作文20篇2020年
我敬佩的一个人作文20篇 我敬佩的一个人作文一): 我身边有很多值得我们敬佩的人,但我最敬佩的一
【发言稿】 日期:2020-11-10
-
纪委书记工作表态发言4篇
纪委书记工作表态发言4篇纪委书记工作表态发言篇1在镇党委政府正确领导下,在全村干部和群众的共同努力下,紧紧围绕建设社会主义新农村工作为重点,尽职尽责,与时俱
【发言稿】 日期:2022-09-30
-
党员教育培训总结交流发言12篇
党员教育培训总结交流发言12篇党员教育培训总结交流发言篇1根据市委组织部《关于开展我市〈20XX
【发言稿】 日期:2022-12-19
-
[钻井队队长(副队长、指导员)岗位HSE应知应会试题(1863)]
钻井队队长(副队长、指导员)岗位HSE应知应会试题(判断题:771;单选题:626;多选题:466)
【贺词】 日期:2020-09-23
-
话剧《家》剧本 话剧剧本:爱的空间
找文章到更多原创-(http: www damishu cn)人物介绍:刘伟,男,32岁,某购物广
【演讲稿】 日期:2020-01-21
-
五言绝句大全500首古诗_五言绝句144首
五言绝句144首 五言绝句(一): 1《春夜喜雨》唐朝·杜甫 好雨知时节,当春乃发生。随风潜入
【祝福语】 日期:2021-03-13
-
2023年中国行政区划调整方案(设想优秀3篇
中国行政区划调整方案(设想优秀民政部第二次行政区划研讨会会议内容一、缩省的意义与原则1.意义1)利于减少中间层次中国行政区划层级之多为世界之最,既使管理成本
【周公解梦】 日期:2024-02-20
-
2023年和儿媳妇在一起幸福的句子3篇
和儿媳妇在一起幸福的句子1、假如人生不曾相遇,我还是那个我,偶尔做做梦,然后,开始日复一日的奔波,淹没在这喧嚣的城市里。我不会了解,这个世界还有这样的一个你
【格言】 日期:2023-11-10
-
XX老干局推进党建与业务深度融合发展工作情况调研报告:党建调研报告
XX老干局推进党建与业务深度融合 发展工作情况的调研报告 党建工作与业务工作融合发展始终是一个充满生
【成语大全】 日期:2020-08-28
-
中国共产党第三代中央领导集体的卓越贡献
中国共产党第三代中央领导集体的卓越贡献 --------------继往开来铸就辉煌 【摘要】改
【成语大全】 日期:2020-03-20
-
信息技术2.0能力点 [全国中小学教师信息技术应用能力提升工程试题题库及参考答案「精编」]
全国中小学教师信息技术应用能力提升工程试题题库及答案(复习资料)一、判断题题库(A为正确,B为错误)
【格言】 日期:2020-11-17
-
党建工作运行机制内容有哪些_构建基层党建工作运行机制探讨
党的基层组织是党在社会基层组织中的战斗堡垒,是党的全部工作和战斗力的基础。加强和改进县级以下各类党的
【经典阅读】 日期:2020-01-22
-
电大现代教育原理_最新国家开放大学电大《现代教育原理》形考任务2试题及答案
最新国家开放大学电大《现代教育原理》形考任务2试题及答案形考任务二一、多项选择题(共17道试题,共3
【成语大全】 日期:2020-07-20
-
集合推理_七,推理与集合
七推理与集合1 期中考试数学成绩出来了,三个好朋友分别考了88分,92分,95分。他们分别考了多少分
【名人名言】 日期:2020-12-18
-
基层党务工作基本内容_党建基本工作有哪些
党建基本工作有哪些(一) 基层党建工作包括哪些内容 选择了大学生村官这条路,你就与农村基层党
【名人名言】 日期:2020-08-06
-
【2020-2021学年高一英语外研版(2019)选择性必修第一册Unit3Faster,higher,strongerSectionⅠ导学讲义】
Unit3 Faster,higher,stronger背景导学MichaelJordan—Head
【歇后语】 日期:2021-04-19
-
关于三农工作重要论述心得体会3篇
关于三农工作重要论述心得体会3篇关于三农工作重要论述心得体会篇1习近平总书记指出:“建设现代化国家离不开农业农村现代化,要继续巩固脱贫攻坚成果,扎实推进乡村
【学习心得体会】 日期:2022-10-29
-
【福生庄隧道坍塌处理方案】 福生庄隧道在哪里
(呼和浩特铁路局大包电气化改造工程指挥部,内蒙古呼和浩特010050)摘要:文章介绍了福生庄隧道
【学习心得体会】 日期:2020-03-05
-
五个一百工程阅读心得体会13篇
五个一百工程阅读心得体会13篇五个一百工程阅读心得体会篇1凡益之道,与时偕行。在全国网络安全和信
【学习心得体会】 日期:2022-12-07
-
城管系统警示教育心得体会9篇
城管系统警示教育心得体会9篇城管系统警示教育心得体会篇1各党支部要召开多种形式的庆七一座谈会,组织广大党员进行座谈,回顾党的光辉历程,畅谈党的丰功伟绩,
【学习心得体会】 日期:2022-10-09
-
发展对象培训主要内容10篇
发展对象培训主要内容10篇发展对象培训主要内容篇1怀着无比激动的心情,我有幸参加了__新区区委党校20__年第四期(区级机关)党员发展对象培训班。这次的学习
【培训心得体会】 日期:2022-09-24
-
凝聚三种力量发展全过程人民民主心得体会12篇
凝聚三种力量发展全过程人民民主心得体会12篇凝聚三种力量发展全过程人民民主心得体会篇1新民主主义革命是指在帝国主义和无产阶级革命时代,殖民地半殖民地国家中的
【学习心得体会】 日期:2022-08-31
-
2022年全国检察长会议心得7篇
2022年全国检察长会议心得7篇2022年全国检察长会议心得篇1眼睛是心灵上的窗户,我们通过眼睛才能看到世间万物,才能看到眼前这美好的一切。拥有一双明亮的眼
【学习心得体会】 日期:2022-10-31
-
在街道深化作风建设推动高质量发展走在前列动员会上讲话
在2023年街道深化作风建设推动高质量发展走在前列动员会上的讲话同志们:今天我们召开“街道深化作风建设推动高质量发展走在前列动员会”,这次会议是街道三季度召开的第一场...
【军训心得体会】 日期:2024-03-17
-
全面从严治党的心得体会800字7篇
全面从严治党的心得体会800字7篇全面从严治党的心得体会800字篇1中国特色社会主义是我们党领导
【学习心得体会】 日期:2022-12-14
-
2月教师党员个人思想汇报5篇
2月教师党员个人思想汇报敬爱的党组织:最近这一个月的时间对于我来说是极不平凡的,在这段时间里我认真学习了文化部网上党校的相关内容,经过长达40小时的
【教师心得体会】 日期:2023-10-15
-
2024年主题教育民主生活会批评与自我批评意见(38条)(范文推荐)
2023年主题教育民主生活会六个方面个人检视、相互批评意见:1 理论学习系统性不强。学习习近平新时代中国特色社会主义思想不深不透,泛泛而学的时候多,深学细照的时候少,特...
【邓小平理论】 日期:2024-03-19
-
2024年交流发言:强化思想理论武装,增强奋进力量(完整)
习近平总书记指出:“一个民族要走在时代前列,就一刻不能没有理论思维,一刻不能没有思想指引。”党的十八大以来,伴随着新时代中国特色社会主义思想在实践中形成发展的历程...
【三个代表】 日期:2024-03-19
-
2024年度镇年度县乡人大代表述职评议活动总结
xx镇20xx年县乡人大代表述职评议活动总结为响应县级人大常委会关于开展县乡两级人大代表述职评议活动,进一步激发代表履职活力,加强代表与人民群众的联系,提高依法履职水平...
【马克思主义】 日期:2024-03-19
-
“千万工程”经验学习体会(研讨材料)
“千万工程”是总书记在浙江工作时亲自谋划、亲自部署、亲自推动的一项重大决策,也是习近平新时代中国特色社会主义思想在之江大地的生动实践。20年来,“千万工程”先后经历...
【三个代表】 日期:2024-03-19
-
2024年在市政协机关工作总结会议上讲话
同志们:刚才,XX同志对市政协机关20XX年工作进行了很好的总结,很精炼,很到位,可以感受到去年机关工作确实可圈可点。XX同志宣读了表彰决定,机关优秀人员代表、先进集体代...
【邓小平理论】 日期:2024-03-18
-
在全区防汛防涝动员暨河长制工作推进会上讲话提纲【完整版】
区长,各位领导,同志们:汛期已经来临,我区城区防涝工作面临强大考验,形势不容乐观。年初,区城区防涝排渍指挥部已经召开专题调度会,修订完善应急预案,建立网格化管理机...
【马克思主义】 日期:2024-03-18
-
2024年镇作风整治工作实施方案(完整文档)
XX镇作风整治工作实施方案为深入贯彻落实党的二十大精神及省市区委深化作风建设的最新要求,突出重点推进干部效能提升,坚持不懈推动作风整治工作纵深发展,根据《关于印发《2...
【毛泽东思想】 日期:2024-03-18
-
2024市优化法治化营商环境规范涉企行政执法实施方案【优秀范文】
xx市优化法治化营商环境规范涉企行政执法实施方案为持续优化法治化营商环境,激发市场主体活力和社会创造力,规范行政执法行为,创新行政执法方式,提升行政执法质效,着力解...
【毛泽东思想】 日期:2024-03-18
-
2024年度关于开展新一轮思想状况摸底排查工作通知(完整)
关于开展新一轮思想状况摸底排查工作的通知为深入贯彻落实关于各地开展干部职工思想状况大摸底大排查情况上的批示要求和改革教育第二次调度会议精神,有针对性做好队伍教育管...
【三个代表】 日期:2024-03-18
-
2024年公路养护中心主任典型事迹材料(完整文档)
“中心的工作就是心中的事业”——公路养护中心主任典型事迹材料**,男,1976年6月出生,1993年参加工作,2000年4月调入**区交通运输局工作,大学本科学历,中共党员,现任**...
【马克思主义】 日期:2024-03-17