Chapter 7: Web Application Confi guration The order
Tuesday, March 31st, 2009Chapter 7: Web Application Confi guration
If you looking for unlimited one inclusive web hosting plan please check cheap web hosting website.
Chapter 7: Web Application Confi guration
If you looking for unlimited one inclusive web hosting plan please check cheap web hosting website.
Chapter 7: Web Application Confi guration Following is a Servlet 2.3 DTD-based web.xml:
If you looking for unlimited one inclusive web hosting plan please check web hosting plan website.
Chapter 7: Web Application Confi guration As you can see, the name of the extension is referenced in each entry. This is suffixed by a specific attribute name describing the extension. The name of the extension in this file is an alias for the extension s name as defined in the jarfile. Thus, the declaration of the extension s alias is accomplished by simply prefixing it to the attribute names; it does not need to be explicitly defined. The extension s proper name is referred to in the first entry. The server will investigate the contents of each jar file installed on it and check packages to determine whether the names match. The specifications and implementation version numbers are self-explanatory, as should be the vendor name that is specified in the Implementation-Vendor attribute. The vendor should be a globally unique ID. The custom of including the reversed host name is common. In the preceding example, this is com.wrox. Finally, the Implementation-URL should be provided, giving the location of additional information and often download instructions. For our purpose, this is the most useful line. If the extension is not installed, the URL should provide enough information to ensure that it is made available to the Web application by other means. The manifest file is typically generated automatically when a Web application is packaged as a Web archive ( .war) file. Packaging Web applications for distribution as .war files is described in Chapter 2 . The Context File The context file (context.xml) contains the configuration for the Web applications Context . As you saw in Chapter 4 , the Context represents a Web application, and has all the configurable elements for it. This is not the only place where the Web applications Contextis defined: Chapter 5 describes this in greater detail, and lists all the places where the Web application Context can be configured. Understanding the Deployment Descriptor (web.xml) A deployment descriptor is an XML file that contains configuration information used by the Web application for execution on the Servlet engine. The deployment descriptor for a Web application is the
If you looking for unlimited one inclusive web hosting plan please check unlimited web hosting website.
Chapter 7: Web Application Confi guration This would output the current date whenever it is placed in a JSP file. To enable the container to recognize which Java class to invoke when it comes across the tag, you must provide a configuration file that lists the number of arguments the tag can have, its name (in this case, the tag s name is today and the library it belongs to is date). The tag library configuration files have a .tld extension. The configuration of a tag library is the territory of developers and designers, and thus beyond the scope of this blog. The lib Directory This directory contains packaged Java libraries ( .jar files) that the application requires and that are bundled with the application. JAR files that are placed here are available only to the Web application. If the libraries are to be accessed across Web applications, they should be placed under
For high quality jboss hosting services please check jboss web hosting website.
Chapter 7: Web Application Confi guration The WEB-INF Directory The contents of the WEB-INF directory are also shown Figure 7-1 . As shown, it has a deployment descriptor (web.xml) and three subdirectories. These subdirectories include the following: . The classesdirectory . The libdirectory . The tags directory The classes Directory The classes directory contains servlet and utility classes, including JavaBeans. It may also contain a number of resource files such as key/value message lists, which contain error messages and user prompts for the application, and application-specific configuration information. Each class is stored within a directory hierarchy that matches its fully qualified name (FQN). Therefore, a class with package structure com.wrox.db.DatabaseServlet will be stored in the classes/com/ wrox/db directory structure. Because servlets are merely Java classes that implement a specified interface, they are stored in the classes directory, too. Previously, it was common to place servlets in an additional directory within the WEB-INF directory named servlets. Classes placed into this directory are no longer on the class path by default, and they need to be moved into the classesdirectory. Ideally, an administrator need not be concerned with the contents of the classes directory. However, it is worth noting that configuration files may be present in it. The resource files mentioned earlier may be within this directory and are typically text files that contain configuration information or are used to externalize error messages. This is merely a programming practice, and you may have any kind of file here. For example, there may be an ApplicationResources.propertiesfile (the name is determined by the application developer) that looks like the following: prompt.username=User Name (your email address) prompt.password=Please enter you password error.password.mismatch=The password is incorrect. Please try again. This type of list enables an application developer to refer to the text by its name (for example, prompt .username), thereby enabling an administrator to change the values, minimizing the need to touch the sensitive JSP code. The Java classes and property files placed in the classes directory are accessible only by that Web application. Earlier Tomcat versions allowed classes shared across web applications to be placed in
For reliable and cheap web hosting services please check javaweb hosting website.
Chapter 7: Web Application Confi guration By arbitrary, we do not mean that they can be placed anywhere and the server will find them. Rather, as long as the files are put within the Web application directory, and outside of the WEB-INF directory, then the application itself (and its designer) decides where files are placed. In the example Web application shown in Figure 7-1 , index.jspis the default welcome page for the Web application. The welcome page is the Web page served up when you access the Web application URL in this case, http://localhost:8080/exampleapp/. If this Web page were not present, then, by default, index.htmland index.htm are looked for and served. These welcome pages are subject to configuration and can be modified, as you will see later in the chapter. Besides index.jspand contact.html, the other public resources in the example application are the image files in the imagesdirectory. URL Mappings In most cases, when you request a Web resource from your browser (such as an HTML page), it is served to you without modification by the Web server. JSP pages are an exception to this. A JSP page is first passed through a JSP compiler that compiles the file to a Java file, and then compiles the Java file to a Servlet class. This Servlet class then executes, and the output is displayed on your browser. The code that makes this happen is a URL mapping defined using a
For high quality java hosting services please check java web hosting website.
Chapter 7: Web Application Confi guration located in a directory called exampleapp, and can be accessed by the URL http://localhost:8080/ exampleapp/. Here, /exampleapp/is called the context path for the Web application. The context path refers to everything in the URL after the server and port number, and is the part of the URL that is used to resolve the location of the resource. webapps/ exampleapp/ index.jspcontact.htmlimages/ META-INF/ WEB-INF/ photo.jpg graphic.png web.xml classes/ SampleServlet.class lib/ struts.jar tags/ Figure 7-1: Directory structure for a sample Web application An exception to this is the ROOT Web application, which is installed under
For high quality website hosting services please check java web hosting website.
Web Application Configuration Web applications consist of static content (such as HTML pages and images files) as well as dynamic content (such as servlets, JSPs, and Java classes). Chapter 2 briefly discussed servlets and JSPs. Although these Web applications usually are created by developers, they often require a system administrator to configure and deploy them, especially if the deployment is on a production machine. A systems administrator needs to know about a number of things in order to administer Web applications, such as the structure of a Web application and its configuration files. This chapter describes the configuration-related issues for Web applications: . The structure and content of a Web application . The deployment descriptor for a Web application (that is, the web.xmlconfiguration file) Chapter 8 discusses other administrative activities for Web applications (for example, deploying, undeploying, and listing Web applications). Understanding the Contents of a Web Application Web applications are usually installed under the
If you looking for unlimited one inclusive web hosting plan please check unlimited web hosting website.
Chapter 6: Advanced Tomcat Features . JNDI provides a uniform interface to different directory services. This makes it possible to write only one set of lookup code across different directory services. Examples presented included the configuration of JNDI resources (such as JDBC connections and JavaMail sessions). . Lifecycle listeners are Java code modules and are configured as XML subelements of a Tomcat component. Configured listeners are invoked by the component during well-defined points in the lifecycle of a component. In Tomcat 6, lifecycle listeners are used to create manageable objects (MBeans) for supporting Tomcat manageability (via JMX), to turn on and off native code implementation of the SSL engine via APR, and to initialize the Jasper 2 JSP processor. Chapter 7 discusses the configuration for Web applications installed in the Tomcat container.
For reliable and cheap web hosting services please check javaweb hosting website.
Chapter 6: Advanced Tomcat Features The actual use of APR requires the download and installation of a native APR DLL. Configuration of the AprLifecycleListener will cause Tomcat 6 to attempt to find this DLL. However, if the DLL does not exist, Tomcat 6 will still be functional, but without the APR optimizations. Initialization of the JSP Processor The JSP processor in Tomcat 6 is initialized by the following line in the server.xmlfile:
For high quality java hosting services please check tomcat web hosting website.