I wondered when I put below code in my JSF.
<h:inputHidden id="patientId" value="#{requestScope['patientId']}"/>
<%=request.getParameter("patientId") %>
My flow is like One.jsf –> On clicking link called backing Bean –> From backing bean navigate to Two.jsf
I am setting patientID in request scope on One.jsf. I can access it on backing bean.
Now on two.jsf using
<%=request.getParameter("patientId") %>
I can access my value-ID but using
<h:inputHidden id="patientId" value="#{requestScope['patientId']}"/>
I can’t access my value-id. Even in html page source doesn’t show me value….??
why is this?
From the Request object you could get both request parameters (those parameters passed to the URL in GET request) and request attributes (request attributes are values stored in the request object and live there until the request completes).
corresponds to request.get/setAttribute(…)
corresponds to request.getParameter() (parameters are read-only and cannot be set).
In your case you can access the value in your managed bean, because it’s stored in the same request where the managed bean is invoked. When the request finishes and a new page is opened you’ll no longer have access to this value because it was associated with the previous request.