Top Description Methods
jakarta.servlet.annotation

public @Interface WebServlet

extends Annotation
Annotations
@Target:TYPE
@Retention:RUNTIME
@Documented
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target

This annotation is used to declare the configuration of a jakarta.servlet.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 jakarta.servlet.http.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)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

asynchronous operation supported by this Servlet
asyncSupported
()

public String

Returns:

description of this Servlet, if present
description
()

public String

Returns:

display name of this Servlet, if present
displayName
()

public WebInitParam[]

Returns:

array of initialization params for this Servlet
initParams
()

public String

Returns:

large icon for this Servlet, if present
largeIcon
()

public int

Returns:

load on startup ordering hint
loadOnStartup
()

public String

Returns:

name of the Servlet
name
()

public String

Returns:

small icon for this Servlet, if present
smallIcon
()

public String[]

Returns:

array of URL patterns to which this Filter applies
urlPatterns
()

public String[]

Returns:

array of URL patterns
value
()

A convenience method, to allow extremely simple annotation of a class.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

asyncSupportedback to summary
public boolean asyncSupported()
Returns:boolean

asynchronous operation supported by this Servlet

descriptionback to summary
public String description()
Returns:String

description of this Servlet, if present

displayNameback to summary
public String displayName()
Returns:String

display name of this Servlet, if present

initParamsback to summary
public WebInitParam[] initParams()
Returns:WebInitParam[]

array of initialization params for this Servlet

largeIconback to summary
public String largeIcon()
Returns:String

large icon for this Servlet, if present

loadOnStartupback to summary
public int loadOnStartup()
Returns:int

load on startup ordering hint

nameback to summary
public String name()
Returns:String

name of the Servlet

smallIconback to summary
public String smallIcon()
Returns:String

small icon for this Servlet, if present

urlPatternsback to summary
public String[] urlPatterns()
Returns:String[]

array of URL patterns to which this Filter applies

valueback to summary
public String[] value()

A convenience method, to allow extremely simple annotation of a class.

Returns:String[]

array of URL patterns

See Also
urlPatterns()