Tomcat 5.0.28 Invoker Servlet
While setting up my first Apache Tomcat installation, I ran into a problem with the invoker servlet. The invoker servlet lets you run servlets without first making changes to the WEB-INF/web.xml file in your web application. All it really does is let Tomcat know that that any servlet classes dropped into the WEB-INF/classes directory should be executable through the path http://hostname/servlet/ServletName. By default starting at version 4.1.12, Tomcat does not allow this behavior simply by coming with a conf/web.xml file that has those lines commented out. From the Tomcat FAQ:
The invoker is a dynamic servlet which allows run-time loading of other servlets based on class name. This servlet is the one that allows http://localhost/servlet/com.foo.MyClass?more=cowbell, where com.foo.MyClass is some class which can be loaded as a servlet but was never explicitly declared in a config file.
In the text I’m following, Core Servlets and JavaServer Pages Volume 1 (2nd Edition), all it says to do in order to turn on the invoker servlet is to edit conf/web.xml and upcomment the following lines:
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
This tells Tomcat that the Invoker Servlet should sit and watch the /servlet path for anything dropped into that directory and treat it as a package-less servlet. That means that you dont’ have to update the web.xml file everytime to change your structure. This is helpful for testing and debugging during development, but should not be used in a deployed server because of security problems. But with version 5.0.28, you also have to uncomment the lines in conf/web.xml that define the location of the classes for the invoker servlet, not just the mappings as shown above. So in order to get the invoker servlet to work, uncomment the following as well from conf/web.xml:
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
If you only uncomment the servlet-mapping invoker elements, Tomcat won’t even start properly. You have to ensure the corresponding Invoker servlet name and class are defined in conf/web.xml as shown above. JavaRanch had some very good information on the invoker servlet and how it works in Tomcat.
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
March 17th, 2008 at 8:47 am
If you are using tomcat 6, need to define privileges for context. In tomcat 5.5.x version no need to define privileges for context. Tomcat 5.5.x take automatically.
Privileges setting can be done in tomcat/conf/context.xml file. Add this line
see the details go to http://www.easywayserver.com/tomcat-installation-configuration.htm