+ Start a Discussion

How to pass query string from one vf page to another in salesforce sites??

i have a sf site where i calculate a variable. and i want this variable to be displayed in another page in the same salesforce site. how to do that??



You can pass this variable as query parameter with url, for example :




and can access in redirected page with help of ApexPages.currentPage().getParameters().get('temp'); method.


Hope this helps.


I think your requirement is value get from URL and have to be pass value to URL from controller


<apex:page >
  <!--get value from url by VF page-->

 Simple sample done check whether you met the requirement


<!--set as site home page-->
<apex:page controller="TestSite">
  <apex:form >
    <apex:commandLink value="Save" action="{!go}">
      <apex:param name="paramName" value="paramValue"/>

public class TestSite {
    public PageReference go() {
        String paramVal = 
        ApexPages.currentPage().getParameters().get('paramName');//value to be passed 
        PageReference pr = page.testPage;
        pr.getParameters().put('paramName', paramVal);//pass value
        return pr.setredirect(true);

<!--testPage -->
<!--add this page for 'site VF pages'-->
  <!--get value from url by VF page-->