Is there anyway in JSF to get the URL, the scriptname, from the address bar that refers to the page I am on? What would that way be?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To get the request URI in the backing bean you’d need to grab the
HttpServletRequestfrom under the JSF’s covers:It offers several methods to get information about the request, such as
getRequestURI(). Most of them are also available throughgetRequestXXX()methods of theExternalContext, but the request URI not.In the view, you can get it by
#{request}. E.g.Alternatively, if you’re actually interested in the JSF view ID (the “script name” as you say yourself), then rather use
UIViewRoot#getViewId():or in the view itself:
or without the context path:
Related: