1

How can I get a complete URI address ( http:// .../ ../.) in JSF using FacesContext ?

Cœur
  • 34,719
  • 24
  • 185
  • 251
atemiz88
  • 129
  • 2
  • 7

1 Answers1

1

Should be something like this:

public String getRequestUrl()
{
    Object request = FacesContext.getCurrentInstance().getExternalContext().getRequest();
    if (request instanceof HttpServletRequest)
    {
        String requestedUrl = ((HttpServletRequest) request).getRequestURL().toString();
        return requestedUrl;
    }

    return "";
}

P.s., since you are new to StackOverflow, please vote my answer up and accept if it helped.

Falcon
  • 3,130
  • 2
  • 23
  • 35