javatomcatservletsinvokerequired

Trying to setup tomcat to use servlets


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?


Solution

  • 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