[OmniFaces utilities] The
getRequestDomainURL()
method returns the HTTP request domain URL. This is the URL with the scheme and domain, without any trailing slash.[OmniFaces utilities] The
getRequestBaseURL()
method returns the HTTP request base URL. This is the URL from the scheme, domain until with context path, including the trailing slash. This is the value you could use in HTML <base>
tag.[OmniFaces utilities] The
getRequestURL()
method returns the HTTP request URL. This is the full request URL as the enduser sees in browser address bar. This does not include the request query string.[OmniFaces utilities] The
getRequestURI()
method returns the HTTP request URI. This is the part after the domain in the request URL, including the leading slash. This does not include the request query string.Method - Faces#getRequestDomainURL() returns the HTTP request domain URL
Method - Faces#getRequestBaseURL() returns the HTTP request base URL
Method - Faces#getRequestURL() returns the HTTP request URL
Method - Faces#getRequestURI() returns the HTTP request URI
See also: Servlets#getRequestURI()
Let's suppose the following HTTP request (faces servlet mapping is a prefix mapping, /faces/*):
http://localhost:8080/MyApp/faces/index.xhtml
Further,
let's apply the above methods, one by one, as follows:
·
get the HTTP request domain URL (Faces#getRequestDomainURL())
import
org.omnifaces.util.Faces;
...
// returns http://localhost:8080
String requestDomainURL =
Faces.getRequestDomainURL();
·
get the HTTP request base URL (Faces#getRequestBaseURL())
import
org.omnifaces.util.Faces;
...
// returns http://localhost:8080/MyApp/
String requestBaseURL =
Faces.getRequestBaseURL();
·
get the HTTP request URL (Faces#getRequestURL())
import
org.omnifaces.util.Faces;
...
// returns http://localhost:8080/MyApp/faces/index.xhtml
String requestURL =
Faces.getRequestURL();
·
get the HTTP request URI (Faces#getRequestURI())
import
org.omnifaces.util.Faces;
...
// returns /MyApp/faces/index.xhtml
String requestURI =
Faces.getRequestURI();
Let's suppose the following HTTP request (faces
servlet mapping is a suffix mapping, *.xhtml):
http://localhost:8080/MyApp/index.xhtml
Further,
let's apply the above methods, one by one, as follows:
·
get the HTTP request domain URL (Faces#getRequestDomainURL())
import
org.omnifaces.util.Faces;
...
// returns http://localhost:8080
String requestDomainURL =
Faces.getRequestDomainURL();
·
get the HTTP request base URL (Faces#getRequestBaseURL())
import
org.omnifaces.util.Faces;
...
// returns http://localhost:8080/MyApp/
String requestBaseURL =
Faces.getRequestBaseURL();
·
get the HTTP request URL (Faces#getRequestURL())
import
org.omnifaces.util.Faces;
...
// returns http://localhost:8080/MyApp/index.xhtml
String requestURL =
Faces.getRequestURL();
·
get the HTTP request URI (Faces#getRequestURI())
import
org.omnifaces.util.Faces;
...
// returns /MyApp/index.xhtml
String requestURI =
Faces.getRequestURI();
Niciun comentariu :
Trimiteți un comentariu