0

In my JSF 2.1 project, I need to get the current URL and I used FacesContext.getViewRoot().getViewId() but it always returns the previous URL.

I also tried request.getServletPath() and request.getRequestURI() but the result was same.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Viniti
  • 125
  • 2
  • 9
  • Explain the difference between 'current' and 'previous' URL. These methods all work as expected for me. – user207421 Oct 14 '14 at 06:57
  • Actually in JSF, when we navigate from one page to another page 'request.getServletPath()' gives URL of previous page from which we have migrated. And I want to get the URL of Current Page. – Viniti Oct 14 '14 at 09:33
  • Eg . If currently i am on '/sample/pages/homePage.xhtml' and if i click on a button, the website redirects to a second page '/sample/pages/workList.xhtml' but the url indicates '/sample/pages/homePage.xhtml' only until i refresh the web page. 'request.getServletPath()' and other such methods gives the result as '/sample/pages/homePage.xhtml' even when i was redirected to '/sample/pages/workList.xhtml'. – Viniti Oct 14 '14 at 09:45

0 Answers0