Entering content frame

Object documentationInvoker Servlet Locate the document in its SAP Library structure

Definition

The invoker servlet is implemented in the InvokerServlet class that is part of the SAP J2EE Engine’s Web Container. It is declared in the global-web.xml descriptor. It is mapped to the /servlet/* pattern.

Use

The invoker servlet is used to invoke servlet classes that are available to the application classloader (these are classes located in the WEB-INF\classes, WEB-INF\lib, WEB-INF\additional-lib directories of the application). It can invoke servlets either by servlet name (as declared in the <servlet-name> tag of the web.xml), or by its fully-qualified class name (in this case the servlet is not necessary to be declared in the web.xml descriptor). This behavior is determined by the value of the InvokeByClassName initialization parameter defined for the invoker servlet:

·        If it has a value of true, then the invoker servlet tries to load the servlet by servlet name first. If it cannot find a match by the servlet name, it tries to find and load the servlet by its class name. This class name must appear after the /servlet/ pattern in the request URL. For example, http://host:port/servlet/mypackage.example.MyServlet invokes the myservlet that has the following declaration in the web.xml file:

<servlet>

   <servlet-name> myservlet </servlet-name>

   <servlet-class> mypackage.example.MyServlet </servlet-class>

</servlet>

Note

The invoker servlet checks whether the requested class is a servlet (that is, it must implement the javax.Servlet interface) when loading it by its class name. If this condition is not met, it will not load the class.

·        If it has value of false, then the invoker tries to load the requested servlet only by its servlet name declaration. If it finds no match, a “File not found” error message is returned to the client. So, the correct URL to invoke our example myservlet servlet is http://host:port/servlet/myservlet.

Caution

You must make sure you do not map any component to the /servlet/* pattern in the web.xml descriptor of your Web application, otherwise you will no longer be able to use the functions of the invoker servlet.

 

Leaving content frame