dev@jsftemplating.java.net

Re: JSFTemplating: How to get the page url?

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Tue, 15 Jan 2008 15:15:26 -0800

Hi Karam,

You can get this information from the request object. If you want to do
this from w/i a JSFT .jsf page, you can do this via an EL expression.
If you cut/paste the following into a .jsf page in your application you
can see what these do:

"ContextPath: #{request.contextPath}<br />
"QueryString: #{request.queryString}<br />
"RequestURI: #{request.requestURI}<br />
"RequestURL: #{request.requestURL}<br />
"ServletPath: #{request.servletPath}<br />

For JSF w/ a *.jsf servlet mapping, the last one will give you want you
want.

If you want to do this via Java, then you can get some of this
information from the ExternalContext. The rest can be obtained directly
from the request object (although you'll have to cast to ServletRequest
or HttpServletRequest... meaning your code won't work in a Portlet
environment). You can get the ExternalContext & request object by doing:

    FacesContext.getCurrentInstance().getExternalContext()

    externalContext.getRequest()

I hope this helps!

Ken

Karam Singh Badesha wrote:
> Hi,
> e.g. One of the page in my app is http://host/CADRe/test.jsf
>
> Is there a way to get the url after the "http://host/CADRe/" in this
> case "test.jsf" in jsftemplating?
>
> thanks
> -Karam