|
|
Table of Contents |
One of the sample servlets provided with the Java Servlet Development Kit is called the snoop servlet. It simply dumps out all of the servlet environment information as shown when you click on the JavaSoft link below:
http://jserv.javasoft.com/servlet/SnoopServlet?key=value
We'll show you how to add any servlet to the VolanoChat server's built-in servlet runner by taking you through an example in which we add the snoop servlet to VolanoChat.
You install the servlet by placing it in the VolanoChat server's
installation directory. For example, to add the snoop servlet, simply
place the file SnoopServlet.class in the server's
vchat2.0.0 directory so that the servlet runner can find
it.
If you do not require a servlet alias or any initialization parameters, you're done. Just invoke the servlet using the servlet runner's port number. If you are currently using a Web browser on the same machine as the VolanoChat server, you could invoke the servlet with something like:
http://localhost:8080/servlet/SnoopServlet
Note that the link above will work only if you actually installed the snoop servlet, you're on the same machine as the VolanoChat server, and you're running its built-in servlet runner on port 8080.
To set up an alias, add the following line to the properties file of
the servlet runner, called servlets.txt by default.
servlet.snoop.code=SnoopServlet
You must restart the VolanoChat server for the new alias to take effect. With the alias defined, you could invoke the snoop servlet with something like:
http://localhost:8080/servlet/snoop
If the servlet you're adding has any initialization parameters, you add them to the properties file of the servlet runner as well. For example, to add the following two initialization parameters to the snoop servlet:
key1=value1 key2=value2
we simply add an additional line for the snoop servlet to the
servlets.txt file, as shown below:
servlet.snoop.code=SnoopServlet servlet.snoop.initArgs=key1=value1,key2=value2
You must restart the VolanoChat server for the new initialization parameters to take effect. Now when you invoke the snoop servlet with:
http://localhost:8080/servlet/snoop
you will see the initialization parameters listed in the snoop servlet's output page.
|
|
Check HTML | Table of Contents |