
Who, what or where is the Invoker? There are web sites that have a lot of pages on them, none of which is served up all that often, and there are other web sites which only host a few web applications,each of which is run in a container service such as Catalina within Tomcat. In the first case, the web site developer / maintainer wants to simply add extra pages to the appropriate directory and have them appear at their own URLs, but in the latter case (s)he will usually want to specifically point individual URLs at individual applications. And on Tomcat, this is done though the
web.xml file.
But just occasionally under Tomcat, there's a requirement to be able to copy a Class that contains a servlet on the web server, and have it available straight away - no mucking about with
web.xml. For example, I'm training systems administrators who will be looking after a system used by Java classes (University ones, not ours!) this week, and their students need to be able to upload a class that contains a servlet, and with minimal fuss and editing, test it on the server. This is where the Invoker comes in.
To enable the invoker ... in the administrator's main web application configuration file (also called web.xml, but in the
conf directory), remove the comments that disable the Invoker in the sample file supplied with the Tomcat distribution. That extra code comes in two sections - one to define what the invoker IS and and other to define how it MAPS - and you need them both. Then kick [restart] your Tomcat.
To use the invoker for a new Servlet ... place the class file in the
WEB-INF/classes subdirectory of your web application, and visit it via a URL of the form:
http://www.sitename.org.uk/webappname/servlet/Whichone
where
webappname is the name of your web application (directory name in the
webapps folder) and
Whichone is the class name - i.e. the file is called Whichone.class. The word "servlet" is 'hard coded' in the web.xml file - you can change it server-wide if you wish!
We go through all of this (and much, much more!) on our
Deploying Apache httpd / Tomcat course.
Illustration - a waiter at Gun Wharf in Portsmouth (written 2009-02-13, updated 2009-02-15)
209e
Associated topics are indexed under
A654 - Web Application Deployment - Configuring and Controlling Tomcat [3043] Gathering information - logging - with log4j. First steps. - (2010-11-12)
[2652] Reading and writing cookies in Java Servlets and JSPs - (2010-02-26)
[2163] CATALINA_OPTS v JAVA_OPTS - What is the difference? - (2009-05-09)
[2061] Tomcat 6 - Annotated Sample Configuration Files - (2009-03-01)
[1994] tomcat-users.xml; what a difference a space made - (2009-01-16)
[1943] Port and Glasses - (2008-12-14)
[1762] WEB-INF (Tomcat) and .htaccess (httpd) - (2008-08-20)
[1553] Automatic startup and shutdown of Tomcat - (2008-02-24)
[1503] Web page (http) error status 405 - (2008-01-12)
[1370] Apache Tomcat Performance Tuning - (2007-09-29)
[1351] Compressing web pages sent out from server. Is it worth it? - (2007-09-14)
[914] A practical example of roles - (2006-11-04)
[907] Browser -> httpd -> Tomcat -> MySQL. Restarting. - (2006-10-28)
[837] Tomcat - Shutdown port - (2006-08-18)
Some other Articles
Confidence, Customer Service and Tourism in MelkshamWiltshire Rail Service Updatehttpd, Tomcat and PHP course enhancementsError: Cant read xxxxx: no such variable (in Tcl Tk)The InvokerSticky Sessions with mod_jk (httpd to Tomcat)The Interview and The LiftJava Tag Libraries / how they work / Tomcat Deployment1234567890 ... coming up on Friday 13thThrough Snow and Flood to Linux and Tomcat