WebXml (Apache Tomcat 8.5.57 API Documentation)

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, DocumentProperties.Encoding

      public class WebXml
      extends XmlEncodingBase
      implements DocumentProperties.Encoding, 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 and Description
    --- | ---
    `protected static String` | `ORDER_OTHERS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WebXml()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAbsoluteOrdering(String fragmentName)`
    `void` | `addAbsoluteOrderingOthers()`
    `void` | `addAfterOrdering(String fragmentName)`
    `void` | `addAfterOrderingOthers()`
    `void` | `addBeforeOrdering(String fragmentName)`
    `void` | `addBeforeOrderingOthers()`
    `void` | `addContextParam(String param, String value)`
    `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(String className)`
    `void` | `addLocaleEncodingMapping(String locale, String encoding)`
    `void` | `addMessageDestination(MessageDestination messageDestination)`
    `void` | `addMessageDestinationRef(MessageDestinationRef messageDestinationRef)`
    `void` | `addMimeMapping(String extension, String mimeType)`
    `void` | `addPostConstructMethods(String clazz, String method)`
    `void` | `addPreDestroyMethods(String clazz, String method)`
    `void` | `addResourceEnvRef(ContextResourceEnvRef resourceEnvRef)`
    `void` | `addResourceRef(ContextResource resourceRef)`
    `void` | `addSecurityConstraint(SecurityConstraint securityConstraint)`
    `void` | `addSecurityRole(String securityRole)`
    `void` | `addServiceRef(ContextService serviceRef)`
    `void` | `addServlet(ServletDef servletDef)`
    `void` | `addServletMapping(String urlPattern, String servletName)`
    `void` | `addServletMappingDecoded(String urlPattern, String servletName)`
    `void` | `addTaglib(String uri, String location)`
    `void` | `addWelcomeFile(String welcomeFile)`
    `void` | `createAbsoluteOrdering()`
    `Set<String>` | `getAbsoluteOrdering()`
    `Set<String>` | `getAfterOrdering()`
    `Set<String>` | `getBeforeOrdering()`
    `Map<String,String>` | `getContextParams()`
    `boolean` | `getDelegate()`
    `boolean` | `getDenyUncoveredHttpMethods()`
    `String` | `getDisplayName()`
    `Map<String,ContextLocalEjb>` | `getEjbLocalRefs()`
    `Map<String,ContextEjb>` | `getEjbRefs()`
    `Map<String,ContextEnvironment>` | `getEnvEntries()`
    `Map<String,ErrorPage>` | `getErrorPages()`
    `Set<FilterMap>` | `getFilterMappings()`
    `Map<String,FilterDef>` | `getFilters()`
    `String` | `getJarName()`
    `JspConfigDescriptor` | `getJspConfigDescriptor()`
    `Set<JspPropertyGroup>` | `getJspPropertyGroups()`
    `Set<String>` | `getListeners()`
    `Map<String,String>` | `getLocaleEncodingMappings()`
    `LoginConfig` | `getLoginConfig()`
    `int` | `getMajorVersion()`
    `Map<String,MessageDestinationRef>` | `getMessageDestinationRefs()`
    `Map<String,MessageDestination>` | `getMessageDestinations()`
    `Map<String,String>` | `getMimeMappings()`
    `int` | `getMinorVersion()`
    `String` | `getName()`
    `Map<String,String>` | `getPostConstructMethods()`
    `Map<String,String>` | `getPreDestroyMethods()`
    `String` | `getPublicId()`
    `Map<String,ContextResourceEnvRef>` | `getResourceEnvRefs()`
    `Map<String,ContextResource>` | `getResourceRefs()`
    `Set<SecurityConstraint>` | `getSecurityConstraints()`
    `Set<String>` | `getSecurityRoles()`
    `Map<String,ContextService>` | `getServiceRefs()`
    `Map<String,String>` | `getServletMappings()`
    `Map<String,ServletDef>` | `getServlets()`
    `SessionConfig` | `getSessionConfig()`
    `Map<String,String>` | `getTaglibs()`
    `URL` | `getURL()`
    `String` | `getVersion()`
    `boolean` | `getWebappJar()`
    `Set<String>` | `getWelcomeFiles()`
    `boolean` | `isDistributable()`
    `boolean` | `isDuplicated()`
    `boolean` | `isMetadataComplete()`
    `boolean` | `isOverridable()`
    `boolean` | `merge(Set<WebXml> fragments)` Merge the supplied web fragments into this main web.xml.
    `static Set<WebXml>` | `orderWebFragments(WebXml application, Map<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(String displayName)`
    `void` | `setDistributable(boolean distributable)`
    `void` | `setDuplicated(boolean duplicated)`
    `void` | `setJarName(String jarName)`
    `void` | `setLoginConfig(LoginConfig loginConfig)`
    `void` | `setMetadataComplete(boolean metadataComplete)`
    `void` | `setName(String name)`
    `void` | `setOverridable(boolean overridable)`
    `void` | `setPublicId(String publicId)`
    `void` | `setReplaceWelcomeFiles(boolean replaceWelcomeFiles)` When merging/parsing web.xml files into this web.xml should the current set be completely replaced?
    `void` | `setSessionConfig(SessionConfig sessionConfig)`
    `void` | `setURL(URL url)`
    `void` | `setVersion(String version)` Set the version for this web.xml file
    `void` | `setWebappJar(boolean webappJar)`
    `String` | `toString()`
    `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, getEncoding, setCharset, setEncoding`

    - ### 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.Encoding

      `setEncoding`

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

      `setCharset`

- - ### Field Detail

    - #### ORDER_OTHERS

          protected static final 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

          public void setDuplicated(boolean duplicated)

    - #### createAbsoluteOrdering

          public void createAbsoluteOrdering()

    - #### addAbsoluteOrdering

          public void addAbsoluteOrdering(String fragmentName)

    - #### addAbsoluteOrderingOthers

          public void addAbsoluteOrderingOthers()

    - #### getAbsoluteOrdering

          public Set<String> getAbsoluteOrdering()

    - #### addAfterOrdering

          public void addAfterOrdering(String fragmentName)

    - #### addAfterOrderingOthers

          public void addAfterOrderingOthers()

    - #### getAfterOrdering

          public Set<String> getAfterOrdering()

    - #### addBeforeOrdering

          public void addBeforeOrdering(String fragmentName)

    - #### addBeforeOrderingOthers

          public void addBeforeOrderingOthers()

    - #### getBeforeOrdering

          public Set<String> getBeforeOrdering()

    - #### getVersion

          public String getVersion()

    - #### setVersion

          public void setVersion(String version)

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

    - #### getPublicId

          public String getPublicId()

    - #### setPublicId

          public void setPublicId(String publicId)

    - #### isMetadataComplete

          public boolean isMetadataComplete()

    - #### setMetadataComplete

          public void setMetadataComplete(boolean metadataComplete)

    - #### getName

          public String getName()

    - #### setName

          public void setName(String name)

    - #### getMajorVersion

          public int getMajorVersion()

    - #### getMinorVersion

          public int getMinorVersion()

    - #### getDisplayName

          public String getDisplayName()

    - #### setDisplayName

          public void setDisplayName(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(String param,
                             String value)

    - #### getContextParams

          public Map<String,String> getContextParams()

    - #### addFilter

          public void addFilter(FilterDef filter)

    - #### getFilters

          public Map<String,FilterDef> getFilters()

    - #### addFilterMapping

          public void addFilterMapping(FilterMap filterMap)

    - #### getFilterMappings

          public Set<FilterMap> getFilterMappings()

    - #### addListener

          public void addListener(String className)

    - #### getListeners

          public Set<String> getListeners()

    - #### addServlet

          public void addServlet(ServletDef servletDef)

    - #### getServlets

          public Map<String,ServletDef> getServlets()

    - #### addServletMapping

          public void addServletMapping(String urlPattern,
                               String servletName)

    - #### addServletMappingDecoded

          public void addServletMappingDecoded(String urlPattern,
                                      String servletName)

    - #### getServletMappings

          public Map<String,String> getServletMappings()

    - #### setSessionConfig

          public void setSessionConfig(SessionConfig sessionConfig)

    - #### getSessionConfig

          public SessionConfig getSessionConfig()

    - #### addMimeMapping

          public void addMimeMapping(String extension,
                            String mimeType)

    - #### getMimeMappings

          public Map<String,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(String welcomeFile)

    - #### getWelcomeFiles

          public Set<String> getWelcomeFiles()

    - #### addErrorPage

          public void addErrorPage(ErrorPage errorPage)

    - #### getErrorPages

          public Map<String,ErrorPage> getErrorPages()

    - #### addTaglib

          public void addTaglib(String uri,
                       String location)

    - #### getTaglibs

          public Map<String,String> getTaglibs()

    - #### addJspPropertyGroup

          public void addJspPropertyGroup(JspPropertyGroup propertyGroup)

    - #### getJspPropertyGroups

          public Set<JspPropertyGroup> getJspPropertyGroups()

    - #### addSecurityConstraint

          public void addSecurityConstraint(SecurityConstraint securityConstraint)

    - #### getSecurityConstraints

          public Set<SecurityConstraint> getSecurityConstraints()

    - #### setLoginConfig

          public void setLoginConfig(LoginConfig loginConfig)

    - #### getLoginConfig

          public LoginConfig getLoginConfig()

    - #### addSecurityRole

          public void addSecurityRole(String securityRole)

    - #### getSecurityRoles

          public Set<String> getSecurityRoles()

    - #### addEnvEntry

          public void addEnvEntry(ContextEnvironment envEntry)

    - #### getEnvEntries

          public Map<String,ContextEnvironment> getEnvEntries()

    - #### addEjbRef

          public void addEjbRef(ContextEjb ejbRef)

    - #### getEjbRefs

          public Map<String,ContextEjb> getEjbRefs()

    - #### addEjbLocalRef

          public void addEjbLocalRef(ContextLocalEjb ejbLocalRef)

    - #### getEjbLocalRefs

          public Map<String,ContextLocalEjb> getEjbLocalRefs()

    - #### addServiceRef

          public void addServiceRef(ContextService serviceRef)

    - #### getServiceRefs

          public Map<String,ContextService> getServiceRefs()

    - #### addResourceRef

          public void addResourceRef(ContextResource resourceRef)

    - #### getResourceRefs

          public Map<String,ContextResource> getResourceRefs()

    - #### addResourceEnvRef

          public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef)

    - #### getResourceEnvRefs

          public Map<String,ContextResourceEnvRef> getResourceEnvRefs()

    - #### addMessageDestinationRef

          public void addMessageDestinationRef(MessageDestinationRef messageDestinationRef)

    - #### getMessageDestinationRefs

          public Map<String,MessageDestinationRef> getMessageDestinationRefs()

    - #### addMessageDestination

          public void addMessageDestination(MessageDestination messageDestination)

    - #### getMessageDestinations

          public Map<String,MessageDestination> getMessageDestinations()

    - #### addLocaleEncodingMapping

          public void addLocaleEncodingMapping(String locale,
                                      String encoding)

    - #### getLocaleEncodingMappings

          public Map<String,String> getLocaleEncodingMappings()

    - #### addPostConstructMethods

          public void addPostConstructMethods(String clazz,
                                     String method)

    - #### getPostConstructMethods

          public Map<String,String> getPostConstructMethods()

    - #### addPreDestroyMethods

          public void addPreDestroyMethods(String clazz,
                                  String method)

    - #### getPreDestroyMethods

          public Map<String,String> getPreDestroyMethods()

    - #### getJspConfigDescriptor

          public JspConfigDescriptor getJspConfigDescriptor()

    - #### setURL

          public void setURL(URL url)

    - #### getURL

          public URL getURL()

    - #### setJarName

          public void setJarName(String jarName)

    - #### getJarName

          public String getJarName()

    - #### setWebappJar

          public void setWebappJar(boolean webappJar)

    - #### getWebappJar

          public boolean getWebappJar()

    - #### getDelegate

          public boolean getDelegate()

    - #### setDelegate

          public void setDelegate(boolean delegate)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### toXml

          public 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(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 Set<WebXml> orderWebFragments(WebXml application,
                                      Map<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

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