0

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.

wilson
  • 281
  • 6
  • 22

1 Answers1

0

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()
Community
  • 1
  • 1
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332