all
My web project run in tomcat.Its path ishttp://localhost:8080/test/index.html.
How to get the url = "http:/localhost:8080/test/" throught ExternalContext?
thanks advanced.
all
My web project run in tomcat.Its path ishttp://localhost:8080/test/index.html.
How to get the url = "http:/localhost:8080/test/" throught ExternalContext?
thanks advanced.
You can access to the context path using ExternalContext#getRequestContextPath. From its javadoc:
Return the portion of the request URI that identifies the web application context for this request.
Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequest method getContextPath().
Usage in code:
FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()