Top Description Inners Methods
javax.servlet

public Interface ServletRegistration

extends Registration
Known Direct Subinterfaces
javax.servlet.ServletRegistration.Dynamic
Imports
java.util.*

Interface through which a Servlet may be further configured.
Since
Servlet 3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ServletRegistration.Dynamic

Interface through which a Servlet registered via one of the addServlet methods on ServletContext may be further configured.

Method Summary

Modifier and TypeMethod and Description
public Set<String>

Returns:

the (possibly empty) Set of URL patterns that are already mapped to a different Servlet
addMapping
(String...
the URL patterns of the servlet mapping
urlPatterns
)

Adds a servlet mapping with the given URL patterns for the Servlet represented by this ServletRegistration.

public Collection<String>

Returns:

a (possibly empty) Collection of the currently available mappings of the Servlet represented by this ServletRegistration
getMappings
()

Gets the currently available mappings of the Servlet represented by this ServletRegistration.

public String

Returns:

the name of the runAs role, or null if the Servlet is configured to run as its caller
getRunAsRole
()

Gets the name of the runAs role of the Servlet represented by this ServletRegistration.

Inherited from javax.servlet.Registration:
getClassNamegetInitParametergetInitParametersgetNamesetInitParametersetInitParameters

Method Detail

addMappingback to summary
public Set<String> addMapping(String... urlPatterns)

Adds a servlet mapping with the given URL patterns for the Servlet represented by this ServletRegistration.

If any of the specified URL patterns are already mapped to a different Servlet, no updates will be performed.

If this method is called multiple times, each successive call adds to the effects of the former.

The returned set is not backed by the ServletRegistration object, so changes in the returned set are not reflected in the ServletRegistration object, and vice-versa.

Parameters
urlPatterns:String[]

the URL patterns of the servlet mapping

Returns:Set<String>

the (possibly empty) Set of URL patterns that are already mapped to a different Servlet

Exceptions
IllegalArgumentException:
if urlPatterns is null or empty
IllegalStateException:
if the ServletContext from which this ServletRegistration was obtained has already been initialized
getMappingsback to summary
public Collection<String> getMappings()

Gets the currently available mappings of the Servlet represented by this ServletRegistration.

If permitted, any changes to the returned Collection must not affect this ServletRegistration.

Returns:Collection<String>

a (possibly empty) Collection of the currently available mappings of the Servlet represented by this ServletRegistration

getRunAsRoleback to summary
public String getRunAsRole()

Gets the name of the runAs role of the Servlet represented by this ServletRegistration.

Returns:String

the name of the runAs role, or null if the Servlet is configured to run as its caller

javax.servlet back to summary

public Interface ServletRegistration.Dynamic

extends ServletRegistration, Dynamic

Interface through which a Servlet registered via one of the addServlet methods on ServletContext may be further configured.

Method Summary

Modifier and TypeMethod and Description
public void
setLoadOnStartup(int
the initialization priority of the Servlet
loadOnStartup
)

Sets the loadOnStartup priority on the Servlet represented by this dynamic ServletRegistration.

public void
setMultipartConfig(MultipartConfigElement
the MultipartConfigElement to be applied to the patterns mapped to the registration
multipartConfig
)

Sets the MultipartConfigElement to be applied to the mappings defined for this ServletRegistration.

public void
setRunAsRole(String
the name of the runAs role
roleName
)

Sets the name of the runAs role for this ServletRegistration.

public Set<String>

Returns:

the (possibly empty) Set of URL patterns that were already the exact target of a security-constraint that was established via the portable deployment descriptor. This method has no effect on the patterns included in the returned set
setServletSecurity
(ServletSecurityElement
the ServletSecurityElement to be applied to the patterns mapped to this ServletRegistration
constraint
)

Sets the ServletSecurityElement to be applied to the mappings defined for this ServletRegistration.

Inherited from javax.servlet.Registration.Dynamic:
setAsyncSupported
Inherited from javax.servlet.ServletRegistration:
addMappinggetMappingsgetRunAsRole

Method Detail

setLoadOnStartupback to summary
public void setLoadOnStartup(int loadOnStartup)

Sets the loadOnStartup priority on the Servlet represented by this dynamic ServletRegistration.

A loadOnStartup value of greater than or equal to zero indicates to the container the initialization priority of the Servlet. In this case, the container must instantiate and initialize the Servlet during the initialization phase of the ServletContext, that is, after it has invoked all of the ServletContextListener objects configured for the ServletContext at their ServletContextListener#contextInitialized method.

If loadOnStartup is a negative integer, the container is free to instantiate and initialize the Servlet lazily.

The default value for loadOnStartup is -1.

A call to this method overrides any previous setting.

Parameters
loadOnStartup:int

the initialization priority of the Servlet

Exceptions
IllegalStateException:
if the ServletContext from which this ServletRegistration was obtained has already been initialized
setMultipartConfigback to summary
public void setMultipartConfig(MultipartConfigElement multipartConfig)

Sets the MultipartConfigElement to be applied to the mappings defined for this ServletRegistration. If this method is called multiple times, each successive call overrides the effects of the former.

Parameters
multipartConfig:MultipartConfigElement

the MultipartConfigElement to be applied to the patterns mapped to the registration

Exceptions
IllegalArgumentException:
if multipartConfig is null
IllegalStateException:
if the ServletContext from which this ServletRegistration was obtained has already been initialized
setRunAsRoleback to summary
public void setRunAsRole(String roleName)

Sets the name of the runAs role for this ServletRegistration.

Parameters
roleName:String

the name of the runAs role

Exceptions
IllegalArgumentException:
if roleName is null
IllegalStateException:
if the ServletContext from which this ServletRegistration was obtained has already been initialized
setServletSecurityback to summary
public Set<String> setServletSecurity(ServletSecurityElement constraint)

Sets the ServletSecurityElement to be applied to the mappings defined for this ServletRegistration.

This method applies to all mappings added to this ServletRegistration up until the point that the ServletContext from which it was obtained has been initialized.

If a URL pattern of this ServletRegistration is an exact target of a security-constraint that was established via the portable deployment descriptor, then this method does not change the security-constraint for that pattern, and the pattern will be included in the return value.

If a URL pattern of this ServletRegistration is an exact target of a security constraint that was established via the javax.servlet.annotation.ServletSecurity annotation or a previous call to this method, then this method replaces the security constraint for that pattern.

If a URL pattern of this ServletRegistration is neither the exact target of a security constraint that was established via the javax.servlet.annotation.ServletSecurity annotation or a previous call to this method, nor the exact target of a security-constraint in the portable deployment descriptor, then this method establishes the security constraint for that pattern from the argument ServletSecurityElement.

The returned set is not backed by the Dynamic object, so changes in the returned set are not reflected in the Dynamic object, and vice-versa.

Parameters
constraint:ServletSecurityElement

the ServletSecurityElement to be applied to the patterns mapped to this ServletRegistration

Returns:Set<String>

the (possibly empty) Set of URL patterns that were already the exact target of a security-constraint that was established via the portable deployment descriptor. This method has no effect on the patterns included in the returned set

Exceptions
IllegalArgumentException:
if constraint is null
IllegalStateException:
if the ServletContext from which this ServletRegistration was obtained has already been initialized