1

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
atemiz88
  • 129
  • 2
  • 8

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,150
  • 2
  • 24
  • 35