![]() |
![]() |
||||
The Invoker Servlet allows unconfigured servlets to be called by simply using a /servlet URL.
It is disabled by default in new Tomcat installations, and new metawerx hosting accounts, for security reasons.
To enable the Invoker Servlet, add the following to your <appName>/WEB-INF/web.xml file, between the <web-app> tags:
<servlet> <servlet-name>MyInvoker</servlet-name> <servlet-class> org.apache.catalina.servlets.InvokerServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>MyInvoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping>
Here is a complete, minimal example of a web.xml file containing the above. If you are not familiar with web.xml at all, just save the following file as <appName>/WEB-INF/web.xml file to get started:
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>My App</display-name> <description> My Application </description> <servlet> <servlet-name>MyInvoker</servlet-name> <servlet-class> org.apache.catalina.servlets.InvokerServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>MyInvoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping> </web-app>