Questo contenuto non è disponibile nella lingua selezionata.

7.3. Context Root


The context root determines the URL of a deployed application. By default, the context root is identical with the application directory or archive structure; for example, if you deploy an application.war archive, which contains JSP pages in a hello directory, the JSPs in the hello directory will be available under /application/hello/.

Procedure 7.2. Rewriting the Default Context Root

You can change the context root if required. To rewrite the context root, you need to define the new context root and allow the server to use the new context.
  1. To define a new context root, add the context-root element with the new value to the deployment descriptor of the application:
    • To change the context root of a web application, add the context-root element to the jboss-web.xml file.

      Example 7.3. Example jboss-web.xml with a context root defined

      <?xml version="1.0"?>
      <jboss-web>
         <context-root>/application-root</context-root>
      </jboss-web>
      Copy to Clipboard Toggle word wrap
      The URL address for the application on localhost is

      http://localhost:8080/application-root

    • To change the context root of a servlet, change the url-pattern element in the web.xml file.

      Example 7.4. Example web.xml with a context root defined

      <?xml version="1.0"?>
      <servlet-mapping>
        <servlet-name>MapRenderer</servlet-name>
        <url-pattern>/servlet-root</url-pattern>
      </servlet-mapping>
      Copy to Clipboard Toggle word wrap
      The URL address for the servlet on localhost is

      http://localhost:8080/application-root/servlet-root

  2. To start the server with the REWRITE_CONTEXT_CHECK variable set to false, run the following command: run.sh -Dorg.apache.catalina.connector.Response.REWRITE_CONTEXT_CHECK=false
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat