I can get the URL or URI just fine. However, JSF seems to exclude any URL parameters. For example:
Suppose the url is: www.example.com/pleasework?param=1
import javax.servlet.http.HttpServletRequest;
public String getUrl() {
HttpServletRequest request = (HttpServletRequest)
FacesContext.getCurrentInstance().getExternalContext().getRequest();
String url = request.getRequestURL().toString();
String uri = request.getRequestURI();
return uri;
}
My result is everything up until the ? but I need everything after the ?
How can I accomplish this in JSF
Note: I need to get the URL server side so using Javascript's window.location.href and storing value in hidden field is not a solution for me because I need the parameters on page load.
getParameterMap()method on therequestobject. Or you can also use thegetParameter(parmName)method.@RequestScopebean. My bean is@SessionScopedand this would not be a solution for me, but perhaps will be for someone else.@Namedwith@Paramworks in sessionscoped beans as well (you did not mention SessionScoped) And for 'page load' there are other solutions too where it is explicit in the page that it is for pageloading: stackoverflow.com/questions/4888942/… where the @Param has additional features for validation etc... Cool thing!