Skip to main content

Find the Context Path with JSF
22 September 2015

Sometimes JSF does not have a component that will produce a particular type of HTML element. That's not a problem but, I always forget the three method deep route to the context path. I always find I have to work through an IDE's code completion tool to find the application's path.

Here it is for next time:

#{facesContext.externalContext.requestContextPath}

A shorter version:

#{request.contextPath}

Just for completeness here is the JSP version:

${pageContext.request.contextPath}

And finaly, the scriptlet version:

<%
    String root = pageContext.getRequest().getServletContext().getContextPath();
%>

If you know any more please do leave a comment.

Tags

Mailing List


Responsive Media

With the ResponsiveMedia plugin for Joomla it is easy to add 3rd party content from YouTube, Vimeo, and Instagram right in to any Joomla! article.

ResponsiveMedia