title: How to get the applicationContext or context-root name on PrimeFaces 7.0
body: <p>I'm trying to get the applicationContext of my web app which is defined on jboss-web.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jboss-web&gt;
      &lt;context-root&gt;/Tesoreria-WEB&lt;/context-root&gt;
      &lt;max-active-sessions&gt;300&lt;/max-active-sessions&gt;
  &lt;/jboss-web&gt;
  </code></pre>
  
  <p>Is there a way to get that String Tesoreria-WEB? I need it because my menus aren't adding that part of the url anymore after upgrading from 3.5 to 7.0, so im gonna get that context and add it before they are created. I had tried with:</p>
  
  <pre><code>    System.out.println("Application name: "+ PrimeRequestContext.getCurrentInstance(FacesContext.getCurrentInstance()).getApplicationContext());
  </code></pre>
  
  <p>but no success, is there a way or should I add it manually? thanks!</p>
  
  <p>By the way I think they stopped adding correctly the url after upgrading to 7.0 from 3.5 because of <a href="https://github.com/primefaces/primefaces/wiki/Migration-Guide" rel="nofollow noreferrer">https://github.com/primefaces/primefaces/wiki/Migration-Guide</a> breaking changes from 6.2 to 7.0 says "Button/Link/MenuItem: The url/href attribute isn't automatically prepended by contextPath anymore. Use the outcome attribute for referencing JSF views in the same application or manually prepend url/href with #{request.contextPath}. See <a href="https://github.com/primefaces/primefaces/issues/3506" rel="nofollow noreferrer">https://github.com/primefaces/primefaces/issues/3506</a>." But I don't understand what does that mean.</p>
  
  <p>how I expect my url to be built (notice Tesoreria-WEB on the url):
  <strong><a href="http://10.13.44.48:8483/Tesoreria-WEB/XHTML/boxes/boxesMassive.xhtml" rel="nofollow noreferrer">http://10.13.44.48:8483/Tesoreria-WEB/XHTML/boxes/boxesMassive.xhtml</a></strong></p>
  
  <p>how they are being built since I upgraded to 7.0 (this brings 404):
  <strong><a href="http://10.13.44.48:8483/XHTML/boxes/boxesMassive.xhtml" rel="nofollow noreferrer">http://10.13.44.48:8483/XHTML/boxes/boxesMassive.xhtml</a></strong></p>
  
  <p>I dynamically made my menuBar on the ManagedBean and on the xhtml I call reference it like this, that's all no menuItems no things like that all is made on the ManagedBean:</p>
  
  <pre><code>&lt;p:menubar id="menuBar" binding="#{menuMB.menuBar}"
                      autoDisplay="false" styleClass="cds-menu-mainmenu"
                      rendered="#{plantillaGeneralMB.habilitarMenu}" /&gt;
  </code></pre>
  
  <p>This is how we dynamically make the menu, while debugging I found where exactly they get their url, its a bit down there I commented where in English:</p>
  
  <p>this Node objects are from org.w3c.dom.Node</p>
  
  <pre><code>private List&lt;SubMenuItem&gt; cargarSubmenus(Node pNodeMenu,
              List&lt;String[]&gt; lJerarquiaTemp, String[] tituloPadre) {
  
          Node nodeSubMenu = null;
          // Obtener la lista de hijos de este nodo.
          NodeList childNodes = pNodeMenu.getChildNodes();
  
          int sizeList = childNodes.getLength();
          List&lt;SubMenuItem&gt; lSubmenus = new ArrayList&lt;&gt;();
          SubMenuItem subMenu = null;
          lJerarquiaTemp.add(tituloPadre);
  
          for (int i = 0; i &lt; sizeList; i++) {
  
              // Obtener el hijo de este nodo correspondiente al indice indicado.
              nodeSubMenu = childNodes.item(i);
  
              // Verificar que efectivamente este nodo sea un Submenu
              if (nodeSubMenu.getNodeName().equals("SUBMENU")) {
  
                  // Verificar que el nodo tenga atributos.
                  if (nodeSubMenu.hasAttributes()) {
  
                      NamedNodeMap map = nodeSubMenu.getAttributes();
                      // Obtener codigo.
                      Node codigo = map.item(0);
                      // Obtener titulo
                      String titulo = nodeSubMenu.getChildNodes().item(1)
                              .getTextContent();
                      // THIS IS THE URL **********************
                      String url = nodeSubMenu.getChildNodes().item(3)
                                  .getTextContent();
  // Im having to add "/Tesoreria-WEB" + url to make my urls well constructed, no idea what changed so much from 3.5 to 7.0 here if someone knows how to make it work without adding this manually its appreciated
                      subMenu = new SubMenuItem(codigo.getTextContent(), titulo,
                              "/Tesoreria-WEB"+url);
  
  
  
  
                      System.out.println("Application name: "+ PrimeRequestContext.getCurrentInstance(FacesContext.getCurrentInstance()).getApplicationContext());
  
  
                      subMenu.setlJerarquia(lJerarquiaTemp);
                      String[] menuInfo = { codigo.getTextContent(), titulo, url };
                      // Si esta nodo tiene mas hijos llamar recursivamente este
                      // metodo.
  
                      if (nodeSubMenu.getChildNodes().item(5) != null
                              &amp;&amp; nodeSubMenu.getChildNodes().item(5)
                                      .getNodeName().equals("SUBMENU")) {
                          subMenu.setlSubmenus(cargarSubmenus(nodeSubMenu,
                                  subMenu.getlJerarquia(), menuInfo));
                      }
  
                      if (nodeSubMenu.getChildNodes().item(5) != null
                              &amp;&amp; nodeSubMenu.getChildNodes().item(5)
                                      .getNodeName().equals("TABS")) {
                          subMenu.setlTabs(cargarTabs(nodeSubMenu.getChildNodes()
                                  .item(5)));
                      }
  
                      // Adicionar este submenu y sus hijos a la lista de submenus
                      // del nodo original.
                      lSubmenus.add(subMenu);
  
                  }
              }
          }
  
          return lSubmenus;
  
      }
  </code></pre>