Chapter 7: Web Application Confi guration The WEB-INF

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 /shared/classes, but this is no longer the case. The tags Directory An optional tags directory within the WEB-INF directory contains configuration files for tag libraries. A tag library is a group of Java classes that define the functionality of dynamic markup tags. For example, you can use a tag that you define as follows:

For reliable and cheap web hosting services please check javaweb hosting website.

Comments are closed.