Package org.apache.tomcat.util.descriptor.web

## Class WebXml

- java.lang.Object
- - org.apache.tomcat.util.descriptor.web.XmlEncodingBase
  - - org.apache.tomcat.util.descriptor.web.WebXml

- All Implemented Interfaces:
    `DocumentProperties.Charset`

      public class WebXml
      extends XmlEncodingBase
      implements DocumentProperties.Charset

  Representation of common elements of web.xml and web-fragment.xml. Provides a repository for parsed data before the elements are merged. Validation is spread between multiple classes: The digester checks for structural correctness (eg single login-config) This class checks for invalid duplicates (eg filter/servlet names) StandardContext will check validity of values (eg URL formats etc)

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected static java.lang.String` | `ORDER_OTHERS` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `WebXml()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addAbsoluteOrdering​(java.lang.String fragmentName)` |
    `void` | `addAbsoluteOrderingOthers()` |
    `void` | `addAfterOrdering​(java.lang.String fragmentName)` |
    `void` | `addAfterOrderingOthers()` |
    `void` | `addBeforeOrdering​(java.lang.String fragmentName)` |
    `void` | `addBeforeOrderingOthers()` |
    `void` | `addContextParam​(java.lang.String param, java.lang.String value)` |
    `void` | `addDuplicate​(java.lang.String duplicate)` |
    `void` | `addEjbLocalRef​(ContextLocalEjb ejbLocalRef)` |
    `void` | `addEjbRef​(ContextEjb ejbRef)` |
    `void` | `addEnvEntry​(ContextEnvironment envEntry)` |
    `void` | `addErrorPage​(ErrorPage errorPage)` |
    `void` | `addFilter​(FilterDef filter)` |
    `void` | `addFilterMapping​(FilterMap filterMap)` |
    `void` | `addJspPropertyGroup​(JspPropertyGroup propertyGroup)` |
    `void` | `addListener​(java.lang.String className)` |
    `void` | `addLocaleEncodingMapping​(java.lang.String locale, java.lang.String encoding)` |
    `void` | `addMessageDestination​(MessageDestination messageDestination)` |
    `void` | `addMessageDestinationRef​(MessageDestinationRef messageDestinationRef)` |
    `void` | `addMimeMapping​(java.lang.String extension, java.lang.String mimeType)` |
    `void` | `addPostConstructMethods​(java.lang.String clazz, java.lang.String method)` |
    `void` | `addPreDestroyMethods​(java.lang.String clazz, java.lang.String method)` |
    `void` | `addResourceEnvRef​(ContextResourceEnvRef resourceEnvRef)` |
    `void` | `addResourceRef​(ContextResource resourceRef)` |
    `void` | `addSecurityConstraint​(SecurityConstraint securityConstraint)` |
    `void` | `addSecurityRole​(java.lang.String securityRole)` |
    `void` | `addServiceRef​(ContextService serviceRef)` |
    `void` | `addServlet​(ServletDef servletDef)` |
    `void` | `addServletMapping​(java.lang.String urlPattern, java.lang.String servletName)` |
    `void` | `addServletMappingDecoded​(java.lang.String urlPattern, java.lang.String servletName)` |
    `void` | `addTaglib​(java.lang.String uri, java.lang.String location)` |
    `void` | `addWelcomeFile​(java.lang.String welcomeFile)` |
    `void` | `createAbsoluteOrdering()` |
    `java.util.Set<java.lang.String>` | `getAbsoluteOrdering()` |
    `java.util.Set<java.lang.String>` | `getAfterOrdering()` |
    `java.util.Set<java.lang.String>` | `getBeforeOrdering()` |
    `java.util.Map<java.lang.String,​java.lang.String>` | `getContextParams()` |
    `boolean` | `getDelegate()` |
    `boolean` | `getDenyUncoveredHttpMethods()` |
    `java.lang.String` | `getDisplayName()` |
    `java.util.List<java.lang.String>` | `getDuplicates()` |
    `java.util.Map<java.lang.String,​ContextLocalEjb>` | `getEjbLocalRefs()` |
    `java.util.Map<java.lang.String,​ContextEjb>` | `getEjbRefs()` |
    `java.util.Map<java.lang.String,​ContextEnvironment>` | `getEnvEntries()` |
    `java.util.Map<java.lang.String,​ErrorPage>` | `getErrorPages()` |
    `java.util.Set<FilterMap>` | `getFilterMappings()` |
    `java.util.Map<java.lang.String,​FilterDef>` | `getFilters()` |
    `java.lang.String` | `getJarName()` |
    `JspConfigDescriptor` | `getJspConfigDescriptor()` |
    `java.util.Set<JspPropertyGroup>` | `getJspPropertyGroups()` |
    `java.util.Set<java.lang.String>` | `getListeners()` |
    `java.util.Map<java.lang.String,​java.lang.String>` | `getLocaleEncodingMappings()` |
    `LoginConfig` | `getLoginConfig()` |
    `int` | `getMajorVersion()` |
    `java.util.Map<java.lang.String,​MessageDestinationRef>` | `getMessageDestinationRefs()` |
    `java.util.Map<java.lang.String,​MessageDestination>` | `getMessageDestinations()` |
    `java.util.Map<java.lang.String,​java.lang.String>` | `getMimeMappings()` |
    `int` | `getMinorVersion()` |
    `java.lang.String` | `getName()` |
    `java.util.Map<java.lang.String,​java.lang.String>` | `getPostConstructMethods()` |
    `java.util.Map<java.lang.String,​java.lang.String>` | `getPreDestroyMethods()` |
    `java.lang.String` | `getPublicId()` |
    `java.lang.String` | `getRequestCharacterEncoding()` |
    `java.util.Map<java.lang.String,​ContextResourceEnvRef>` | `getResourceEnvRefs()` |
    `java.util.Map<java.lang.String,​ContextResource>` | `getResourceRefs()` |
    `java.lang.String` | `getResponseCharacterEncoding()` |
    `java.util.Set<SecurityConstraint>` | `getSecurityConstraints()` |
    `java.util.Set<java.lang.String>` | `getSecurityRoles()` |
    `java.util.Map<java.lang.String,​ContextService>` | `getServiceRefs()` |
    `java.util.Map<java.lang.String,​java.lang.String>` | `getServletMappings()` |
    `java.util.Map<java.lang.String,​ServletDef>` | `getServlets()` |
    `SessionConfig` | `getSessionConfig()` |
    `java.util.Map<java.lang.String,​java.lang.String>` | `getTaglibs()` |
    `java.net.URL` | `getURL()` |
    `java.lang.String` | `getVersion()` |
    `boolean` | `getWebappJar()` |
    `java.util.Set<java.lang.String>` | `getWelcomeFiles()` |
    `boolean` | `isDistributable()` |
    `boolean` | `isDuplicated()` |
    `boolean` | `isMetadataComplete()` |
    `boolean` | `isOverridable()` |
    `boolean` | `merge​(java.util.Set<WebXml> fragments)` | Merge the supplied web fragments into this main web.xml.
    `static java.util.Set<WebXml>` | `orderWebFragments​(WebXml application, java.util.Map<java.lang.String,​WebXml> fragments, ServletContext servletContext)` | Generates the sub-set of the web-fragment.xml files to be processed in the order that the fragments must be processed as per the rules in the Servlet spec.
    `void` | `setAlwaysAddWelcomeFiles​(boolean alwaysAddWelcomeFiles)` | When merging from this web.xml, should the welcome files be added to the target web.xml even if it already contains welcome file definitions.
    `void` | `setDelegate​(boolean delegate)` |
    `void` | `setDenyUncoveredHttpMethods​(boolean denyUncoveredHttpMethods)` |
    `void` | `setDisplayName​(java.lang.String displayName)` |
    `void` | `setDistributable​(boolean distributable)` |
    `void` | `setDuplicated​(boolean duplicated)` | Deprecated.
    `void` | `setJarName​(java.lang.String jarName)` |
    `void` | `setLoginConfig​(LoginConfig loginConfig)` |
    `void` | `setMetadataComplete​(boolean metadataComplete)` |
    `void` | `setName​(java.lang.String name)` |
    `void` | `setOverridable​(boolean overridable)` |
    `void` | `setPublicId​(java.lang.String publicId)` |
    `void` | `setReplaceWelcomeFiles​(boolean replaceWelcomeFiles)` | When merging/parsing web.xml files into this web.xml should the current set be completely replaced?
    `void` | `setRequestCharacterEncoding​(java.lang.String requestCharacterEncoding)` |
    `void` | `setResponseCharacterEncoding​(java.lang.String responseCharacterEncoding)` |
    `void` | `setSessionConfig​(SessionConfig sessionConfig)` |
    `void` | `setURL​(java.net.URL url)` |
    `void` | `setVersion​(java.lang.String version)` | Set the version for this web.xml file
    `void` | `setWebappJar​(boolean webappJar)` |
    `java.lang.String` | `toString()` |
    `java.lang.String` | `toXml()` | Generate a web.xml in String form that matches the representation stored in this object.

    - ### Methods inherited from class org.apache.tomcat.util.descriptor.web.XmlEncodingBase

      `getCharset, setCharset`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.tomcat.util.digester.DocumentProperties.Charset

      `setCharset`

- - ### Field Detail

    - #### ORDER_OTHERS

          protected static final java.lang.String ORDER_OTHERS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### WebXml

          public WebXml()

  - ### Method Detail

    - #### isOverridable

          public boolean isOverridable()

    - #### setOverridable

          public void setOverridable​(boolean overridable)

    - #### isDuplicated

          public boolean isDuplicated()

    - #### setDuplicated

          @Deprecated
          public void setDuplicated​(boolean duplicated)

      Deprecated.

    - #### addDuplicate

          public void addDuplicate​(java.lang.String duplicate)

    - #### getDuplicates

          public java.util.List<java.lang.String> getDuplicates()

    - #### createAbsoluteOrdering

          public void createAbsoluteOrdering()

    - #### addAbsoluteOrdering

          public void addAbsoluteOrdering​(java.lang.String fragmentName)

    - #### addAbsoluteOrderingOthers

          public void addAbsoluteOrderingOthers()

    - #### getAbsoluteOrdering

          public java.util.Set<java.lang.String> getAbsoluteOrdering()

    - #### addAfterOrdering

          public void addAfterOrdering​(java.lang.String fragmentName)

    - #### addAfterOrderingOthers

          public void addAfterOrderingOthers()

    - #### getAfterOrdering

          public java.util.Set<java.lang.String> getAfterOrdering()

    - #### addBeforeOrdering

          public void addBeforeOrdering​(java.lang.String fragmentName)

    - #### addBeforeOrderingOthers

          public void addBeforeOrderingOthers()

    - #### getBeforeOrdering

          public java.util.Set<java.lang.String> getBeforeOrdering()

    - #### getVersion

          public java.lang.String getVersion()

    - #### setVersion

          public void setVersion​(java.lang.String version)

      Set the version for this web.xml file
      Parameters:
        `version` - Values of `null` will be ignored

    - #### getPublicId

          public java.lang.String getPublicId()

    - #### setPublicId

          public void setPublicId​(java.lang.String publicId)

    - #### isMetadataComplete

          public boolean isMetadataComplete()

    - #### setMetadataComplete

          public void setMetadataComplete​(boolean metadataComplete)

    - #### getName

          public java.lang.String getName()

    - #### setName

          public void setName​(java.lang.String name)

    - #### getMajorVersion

          public int getMajorVersion()

    - #### getMinorVersion

          public int getMinorVersion()

    - #### getDisplayName

          public java.lang.String getDisplayName()

    - #### setDisplayName

          public void setDisplayName​(java.lang.String displayName)

    - #### isDistributable

          public boolean isDistributable()

    - #### setDistributable

          public void setDistributable​(boolean distributable)

    - #### getDenyUncoveredHttpMethods

          public boolean getDenyUncoveredHttpMethods()

    - #### setDenyUncoveredHttpMethods

          public void setDenyUncoveredHttpMethods​(boolean denyUncoveredHttpMethods)

    - #### addContextParam

          public void addContextParam​(java.lang.String param,
                                      java.lang.String value)

    - #### getContextParams

          public java.util.Map<java.lang.String,​java.lang.String> getContextParams()

    - #### addFilter

          public void addFilter​(FilterDef filter)

    - #### getFilters

          public java.util.Map<java.lang.String,​FilterDef> getFilters()

    - #### addFilterMapping

          public void addFilterMapping​(FilterMap filterMap)

    - #### getFilterMappings

          public java.util.Set<FilterMap> getFilterMappings()

    - #### addListener

          public void addListener​(java.lang.String className)

    - #### getListeners

          public java.util.Set<java.lang.String> getListeners()

    - #### addServlet

          public void addServlet​(ServletDef servletDef)

    - #### getServlets

          public java.util.Map<java.lang.String,​ServletDef> getServlets()

    - #### addServletMapping

          public void addServletMapping​(java.lang.String urlPattern,
                                        java.lang.String servletName)

    - #### addServletMappingDecoded

          public void addServletMappingDecoded​(java.lang.String urlPattern,
                                               java.lang.String servletName)

    - #### getServletMappings

          public java.util.Map<java.lang.String,​java.lang.String> getServletMappings()

    - #### setSessionConfig

          public void setSessionConfig​(SessionConfig sessionConfig)

    - #### getSessionConfig

          public SessionConfig getSessionConfig()

    - #### addMimeMapping

          public void addMimeMapping​(java.lang.String extension,
                                     java.lang.String mimeType)

    - #### getMimeMappings

          public java.util.Map<java.lang.String,​java.lang.String> getMimeMappings()

    - #### setReplaceWelcomeFiles

          public void setReplaceWelcomeFiles​(boolean replaceWelcomeFiles)

      When merging/parsing web.xml files into this web.xml should the current set be completely replaced?
      Parameters:
        `replaceWelcomeFiles` - `true` to replace welcome files rather than add to the list

    - #### setAlwaysAddWelcomeFiles

          public void setAlwaysAddWelcomeFiles​(boolean alwaysAddWelcomeFiles)

      When merging from this web.xml, should the welcome files be added to the target web.xml even if it already contains welcome file definitions.
      Parameters:
        `alwaysAddWelcomeFiles` - `true` to add welcome files

    - #### addWelcomeFile

          public void addWelcomeFile​(java.lang.String welcomeFile)

    - #### getWelcomeFiles

          public java.util.Set<java.lang.String> getWelcomeFiles()

    - #### addErrorPage

          public void addErrorPage​(ErrorPage errorPage)

    - #### getErrorPages

          public java.util.Map<java.lang.String,​ErrorPage> getErrorPages()

    - #### addTaglib

          public void addTaglib​(java.lang.String uri,
                                java.lang.String location)

    - #### getTaglibs

          public java.util.Map<java.lang.String,​java.lang.String> getTaglibs()

    - #### addJspPropertyGroup

          public void addJspPropertyGroup​(JspPropertyGroup propertyGroup)

    - #### getJspPropertyGroups

          public java.util.Set<JspPropertyGroup> getJspPropertyGroups()

    - #### addSecurityConstraint

          public void addSecurityConstraint​(SecurityConstraint securityConstraint)

    - #### getSecurityConstraints

          public java.util.Set<SecurityConstraint> getSecurityConstraints()

    - #### setLoginConfig

          public void setLoginConfig​(LoginConfig loginConfig)

    - #### getLoginConfig

          public LoginConfig getLoginConfig()

    - #### addSecurityRole

          public void addSecurityRole​(java.lang.String securityRole)

    - #### getSecurityRoles

          public java.util.Set<java.lang.String> getSecurityRoles()

    - #### addEnvEntry

          public void addEnvEntry​(ContextEnvironment envEntry)

    - #### getEnvEntries

          public java.util.Map<java.lang.String,​ContextEnvironment> getEnvEntries()

    - #### addEjbRef

          public void addEjbRef​(ContextEjb ejbRef)

    - #### getEjbRefs

          public java.util.Map<java.lang.String,​ContextEjb> getEjbRefs()

    - #### addEjbLocalRef

          public void addEjbLocalRef​(ContextLocalEjb ejbLocalRef)

    - #### getEjbLocalRefs

          public java.util.Map<java.lang.String,​ContextLocalEjb> getEjbLocalRefs()

    - #### addServiceRef

          public void addServiceRef​(ContextService serviceRef)

    - #### getServiceRefs

          public java.util.Map<java.lang.String,​ContextService> getServiceRefs()

    - #### addResourceRef

          public void addResourceRef​(ContextResource resourceRef)

    - #### getResourceRefs

          public java.util.Map<java.lang.String,​ContextResource> getResourceRefs()

    - #### addResourceEnvRef

          public void addResourceEnvRef​(ContextResourceEnvRef resourceEnvRef)

    - #### getResourceEnvRefs

          public java.util.Map<java.lang.String,​ContextResourceEnvRef> getResourceEnvRefs()

    - #### addMessageDestinationRef

          public void addMessageDestinationRef​(MessageDestinationRef messageDestinationRef)

    - #### getMessageDestinationRefs

          public java.util.Map<java.lang.String,​MessageDestinationRef> getMessageDestinationRefs()

    - #### addMessageDestination

          public void addMessageDestination​(MessageDestination messageDestination)

    - #### getMessageDestinations

          public java.util.Map<java.lang.String,​MessageDestination> getMessageDestinations()

    - #### addLocaleEncodingMapping

          public void addLocaleEncodingMapping​(java.lang.String locale,
                                               java.lang.String encoding)

    - #### getLocaleEncodingMappings

          public java.util.Map<java.lang.String,​java.lang.String> getLocaleEncodingMappings()

    - #### addPostConstructMethods

          public void addPostConstructMethods​(java.lang.String clazz,
                                              java.lang.String method)

    - #### getPostConstructMethods

          public java.util.Map<java.lang.String,​java.lang.String> getPostConstructMethods()

    - #### addPreDestroyMethods

          public void addPreDestroyMethods​(java.lang.String clazz,
                                           java.lang.String method)

    - #### getPreDestroyMethods

          public java.util.Map<java.lang.String,​java.lang.String> getPreDestroyMethods()

    - #### getJspConfigDescriptor

          public JspConfigDescriptor getJspConfigDescriptor()

    - #### getRequestCharacterEncoding

          public java.lang.String getRequestCharacterEncoding()

    - #### setRequestCharacterEncoding

          public void setRequestCharacterEncoding​(java.lang.String requestCharacterEncoding)

    - #### getResponseCharacterEncoding

          public java.lang.String getResponseCharacterEncoding()

    - #### setResponseCharacterEncoding

          public void setResponseCharacterEncoding​(java.lang.String responseCharacterEncoding)

    - #### setURL

          public void setURL​(java.net.URL url)

    - #### getURL

          public java.net.URL getURL()

    - #### setJarName

          public void setJarName​(java.lang.String jarName)

    - #### getJarName

          public java.lang.String getJarName()

    - #### setWebappJar

          public void setWebappJar​(boolean webappJar)

    - #### getWebappJar

          public boolean getWebappJar()

    - #### getDelegate

          public boolean getDelegate()

    - #### setDelegate

          public void setDelegate​(boolean delegate)

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### toXml

          public java.lang.String toXml()

      Generate a web.xml in String form that matches the representation stored in this object.
      Returns:
        The complete contents of web.xml as a String

    - #### merge

          public boolean merge​(java.util.Set<WebXml> fragments)

      Merge the supplied web fragments into this main web.xml.
      Parameters:
        `fragments` - The fragments to merge in
      Returns:
        `true` if merge is successful, else `false`

    - #### orderWebFragments

          public static java.util.Set<WebXml> orderWebFragments​(WebXml application,
                                                                java.util.Map<java.lang.String,​WebXml> fragments,
                                                                ServletContext servletContext)

      Generates the sub-set of the web-fragment.xml files to be processed in the order that the fragments must be processed as per the rules in the Servlet spec.
      Parameters:
        `application` - The application web.xml file
        `fragments` - The map of fragment names to web fragments
        `servletContext` - The servlet context the fragments are associated with
      Returns:
        Ordered list of web-fragment.xml files to process