Metawerx Java Hosting Small Logo

<servlet>

This is a container tag used to specify a Java servlet and it's parameters.

Servlets cannot be called directly unless the InvokerServlet is enabled, so one or more servlet tags and servlet-mappings must exist for each servlet, to tell Tomcat when to call the servlet.

There are two required elements:

  • <servlet-name> - the servlet name, this is used to match the <servlet-name> element in one or more <servlet-mapping> tags
  • <servlet-class> - the canonical class name of the servlet (eg: SimpleServlet or com.metawerx.servlets.SimpleServlet if it's in a package)

Full Servlet Definition Example


    <!-- Simple Servlet, provide a name, class, description and map to URL /servlet/SimpleServlet -->
    <servlet>
            <servlet-name>Simple</servlet-name>
            <servlet-class>SimpleServlet</servlet-class>
            <description>This is a simple Hello World servlet</description>
    </servlet>
    <servlet-mapping>
            <servlet-name>Simple</servlet-name>
            <url-pattern>/servlet/SimpleServlet</url-pattern>
    </servlet-mapping>

See Also

  • web.xml reference guide for a full example of using the servlet tag and it's child elements
navigation
metawerx specific
search
Share
tools
help

referring pages

Share