1

I'm following instructions found in Java All in one for Dummies 3rd edition

I downloaded tomcat and followed all the steps for setting it up, step 6 says. "Modify the web.xml file to enable the invoker servlet" It says to find the lines of code for the invoker and then comment them. I am currently in the web.xml file and searched for invoke, but nothing came up... should I code the invoker in myself? or umcomment a different line?(this book is 4 years old and may be outdated) Or just not change anything at all?

Explorer
  • 1,491
  • 4
  • 26
  • 67
user3527058
  • 23
  • 1
  • 5
  • as not everybody may have this book you should quote the web.xml file. Which version of Tomcat do you use ? What is there besides the web.xml ? Give us more details – Marged Jun 15 '15 at 20:26
  • 1
    Looks like you're reading a very old book. Nowadays, you should use `@WebServlet` annotation rather than playing with the web.xml file. – Luiggi Mendoza Jun 15 '15 at 20:32

2 Answers2

2

I've just take a quick look up to the book and on page 407, there are the lines that you have to decomment or/else if not exist, add.

From the book;

<!--
     <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>
 -->

Anything located in between the "<!--" and "-->" will be interpreted as comments, which won't have any functional effect.

What you have to do is, to delete/remove the "<!--" and "-->" parts of this. Which is;

     <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>

As it is written on the book, on the same "web.xml" file, you also have to find the lines below;

<!--
    <servlet-mapping>
        <servlet-name>invoker</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping
 -->

And commenting out them to make them visible to the tomcat, as removing the same comment lines, like below;

<servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
</servlet-mapping

Remember, you all have to execute these on the web.xml file.

And one more thing, If you cannot find these two parts, you can simply add these as below;

Just add them to the web.xml file as is;

     <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>


    <servlet-mapping>
        <servlet-name>invoker</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping
Levent Divilioglu
  • 11,198
  • 5
  • 59
  • 106
0

Just for your reference, this is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>IPNListener</display-name>
 <servlet>
        <servlet-name>PaypalListenerServlet</servlet-name> //your servlet name
        <servlet-class>com.paypal.ipn.PaypalListenerServlet</servlet-class>// your actual java class
    </servlet>
    <servlet-mapping>
        <servlet-name>PaypalListenerServlet</servlet-name>
        <url-pattern>/*</url-pattern>//pattern of your calling url
    </servlet-mapping>
</web-app>

Further you can give a look here for understanding of this web.xml file

SSH
  • 1,609
  • 2
  • 22
  • 42