code: public static String getServletContextPath(ExternalContext ec)
      {
          if (!isPortlet(ec))
          {
              return ((ServletContext) ec.getContext()).getContextPath();
          }
          else
          {
              return null;
          }
      }
docs: Returns the contextPath of the ServletContext or <code>null</code> for portlets
  
  @param ec the current external context
  @return a String containing the servletContextPath