Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you ever need to haul the raw Servlet API from under the JSF hoods by the <code>FacesContext</code>, then chances are that you're doing the job at the wrong place. What is it, the functional requirement for which you thought that this is the right solution? Should you maybe not be using a real <code>Servlet</code> class or a <code>Filter</code> instead of a JSF managed bean? Or maybe don't you need the request URL at all because there are better "jsfish" ways to achieve the same?</p> <p>If you update your question to include the detail about the functional requirement, then we may be able to suggest the right solution.</p> <hr> <p><strong>Update</strong> as per your edit: so, you just need it after all in the view side? E.g. <code>#{bean.requestURL}</code>? You can also just grab it from the <code>HttpServletRequest</code> object which is already implicitly available in EL. </p> <p>When you're on JSP:</p> <pre><code>${pageContext.request.requestURL} </code></pre> <p>Or when you're on Facelets:</p> <pre><code>#{request.requestURL} </code></pre> <p>And now, how do you need it for JavaScript? Printing as a JavaScript variable? Like so?</p> <pre><code>var url = '#{request.requestURL}'; </code></pre> <p>If so, you could also just grab <a href="https://developer.mozilla.org/en/window.location" rel="noreferrer"><code>window.location</code></a> for that.</p> <pre><code>var url = window.location; </code></pre> <p>No need to clutter the JSF bean with the view specific details.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload