WebServlet (Servlet 3.0 API Documentation - Apache Tomcat 7.0.104)

javax.servlet.annotation

## Annotation Type WebServlet

-     @Target(value=TYPE)
      @Retention(value=RUNTIME)
      @Documented
      public @interface WebServlet

  This annotation is used to declare the configuration of an `Servlet`.
  If the name attribute is not defined, the fully qualified name of the class is used.
  At least one URL pattern MUST be declared in either the `value` or `urlPattern` attribute of the annotation, but not both.
  The `value` attribute is recommended for use when the URL pattern is the only attribute being set, otherwise the `urlPattern` attribute should be used.
  The class on which this annotation is declared MUST extend `HttpServlet`.
  E.g. `@WebServlet("/path")}
  public class TestServlet extends HttpServlet ... {`
  E.g. `@WebServlet(name="TestServlet", urlPatterns={"/path", "/alt"})
  public class TestServlet extends HttpServlet ... {`
  Since:
    Servlet 3.0 (Section 8.1.1)

- - ### Optional Element Summary

    Optional Elements
    Modifier and Type | Optional Element and Description
    --- | ---
    `boolean` | `asyncSupported`
    `java.lang.String` | `description`
    `java.lang.String` | `displayName`
    `WebInitParam[]` | `initParams`
    `java.lang.String` | `largeIcon`
    `int` | `loadOnStartup`
    `java.lang.String` | `name`
    `java.lang.String` | `smallIcon`
    `java.lang.String[]` | `urlPatterns`
    `java.lang.String[]` | `value` A convenience method, to allow extremely simple annotation of a class.

- - ### Element Detail

    - #### name

          public abstract java.lang.String name

      Returns:
        name of the Servlet
      Default:
        ""

    - #### value

          public abstract java.lang.String[] value

      A convenience method, to allow extremely simple annotation of a class.
      Returns:
        array of URL patterns
      See Also:
        `urlPatterns()`
      Default:
        {}

    - #### urlPatterns

          public abstract java.lang.String[] urlPatterns

      Returns:
        array of URL patterns to which this Filter applies
      Default:
        {}

    - #### loadOnStartup

          public abstract int loadOnStartup

      Returns:
        load on startup ordering hint
      Default:
        -1

    - #### initParams

          public abstract WebInitParam[] initParams

      Returns:
        array of initialization params for this Servlet
      Default:
        {}

    - #### asyncSupported

          public abstract boolean asyncSupported

      Returns:
        asynchronous operation supported by this Servlet
      Default:
        false

    - #### smallIcon

          public abstract java.lang.String smallIcon

      Returns:
        small icon for this Servlet, if present
      Default:
        ""

    - #### largeIcon

          public abstract java.lang.String largeIcon

      Returns:
        large icon for this Servlet, if present
      Default:
        ""

    - #### description

          public abstract java.lang.String description

      Returns:
        description of this Servlet, if present
      Default:
        ""

    - #### displayName

          public abstract java.lang.String displayName

      Returns:
        display name of this Servlet, if present
      Default:
        ""

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.