I'm using tuckey URL rewriting with JSF.
I would like to get the relative URL including parameters that the user sees: e.g.
example.com/mypage?param=test
At the moment if I do
#{view.viewId}
I get
mypage.xhtml
what I want to get is:
mypage?param=test
The
UIViewRoot#getViewId()
returns the JSF view ID. You need to useHttpServletRequest#getRequestURI()
to obtain the current request URI andHttpServletRequest#getQueryString()
to obtain the current request query string.Or, if it's a forwarded request, get it as a request attribute keyed with
RequestDispatcher.FORWARD_REQUEST_URI
andRequestDispatcher.FORWARD_QUERY_STRING
respectively:Clumsy yes. Consider hiding away in
<c:set>
of a master template, or an utility tag/function.