2 Replies Latest reply on Sep 1, 2006 1:59 PM by mzeijen

    How do I access the Context Path of the Web App?

    sjmenden

      I am using facelets, seam, ect..

      In my previous projects, I always avoided hard coded cotext paths with jstl:

      <c:url value="/images/myimage.png"/>

      How can I duplicate this in jsf/facelets?

        • 1. Re: How do I access the Context Path of the Web App?
          sjmenden

          I just found this:

          #{facesContext.externalContext.requestContextPath}

          Is there any other way?

          • 2. Re: How do I access the Context Path of the Web App?
            mzeijen

            Use the #{facesContext.externalContext.requestContextPath} to set the base url like this:

            <base href="http://localhost:8080#{facesContext.externalContext.requestContextPath}/"


            The only thing wrong in this example is the http://localhost:8080. This also should come from a variable. I haven't looked into that yet.

            With the base tag in you head of the application you only have to refer to your images on a relative way:

            <link href="include/css/screen.css" rel="stylesheet" type="text/css" />