Java Reference
In-Depth Information
the application, will not load unless they are mapped for execution by the
InvokerServlet within Tomcat. Recall that if a dynamic resource such as a servlet
is requested, the servlet either is loaded directly or a class called InvokerServlet
will load and execute the servlet.
Servlets usually are loaded from WEB-INF\classes under the application's root
folder. For Web applications using the default package, the root folder is the default
root folder, located at webapps\ROOT within the Tomcat folder. If you installed to
the default location as described in Appendix B, the full path for this folder is
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT. All
HTML documents and JSP files are placed in this folder, if they are not within an
application package. Compiled servlet class files then are located in C:\Program
Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\classes.
To have the InvokerServlet execute servlets from the default servlet folder, a
file in the WEB-INF folder may need modification. This file is web.xml and is
called a deployment descriptor. A deployment descriptor is an XML file that is
used to configure a Web application. Servlets in packages may have a specific
entry in the deployment descriptor that maps to the servlet location. Servlets
without a specific entry in the deployment descriptor are known as anonymous
servlets .
To load anonymous servlets, the deployment descriptor needs an entry
indicating that all servlets called with a relative URL of servlet/* will be executed
by the InvokerServlet. The asterisk (*) refers to any servlet name. Figure 12-77
displays the modified portion of the deployment descriptor for anonymous
classes in the default class folder. The color highlighting is controlled by a syntax
file for XML files. As indicated earlier, free syntax files enabling syntax highlight-
ing for various file types, including XML, are available on the TextPad Web site.
41
42 <!-- added the following for invoker servlet -->
43
<servlet>
44
<servlet-name>invoker</servlet-name>
45
<servlet-class>
46
org.apache.catalina.servlets.InvokerServlet
47
</servlet-class>
48
</servlet>
49
50
<servlet-mapping>
51
<servlet-name>invoker</servlet-name>
52
<url-pattern>/servlet/*</url-pattern>
53
</servlet-mapping>
54
55 </web-app>
56
FIGURE 12-77
Loading anonymous servlets originally was enabled by default in Tomcat.
The web.xml file in the conf folder (e.g., C:\Program Files\Apache Software
Foundation\Tomcat 5.5\conf) has the required XML tags, but they are com-
mented out to reduce potential security issues. Using anonymous servlets is not
advisable in a production environment; however, it is acceptable for develop-
Search WWH ::




Custom Search