+ Start a Discussion

How to send the parameters one page to another page using Apex class?

Hi all,


How to send the parameters one page to another page using Apex class?



Thank u for u r help....


through query string params or through properties


Can you please give me one example?.......


can u use the same controller for the two pages?


through query string



  consider u r clicking on a button or link then click redirects to second page then 

u can set the url for the secong page as https://c.cs6.visual.force.com/apex/secondpage?var1=value1&var2=value2.. var1 and var2 are queryb string params and u can access them in the second page using

Apexpages.currentPage().getParameters().get('var1')......like this.. 




i am not getting the code correctly.


here is my code:


1st page:

<apex:page controller="passvalues">
<apex:form >
<H1> Passing Values from one page to another page</H1>
<br />
Enter First Value : <apex:inputText value="{!value1}"/>
Enater Second Value : <apex:inputText value="{!value2}"/>
<apex:commandButton value="Go to Second Page" action="{!Nagivatepage}" />



1st class:

public with sharing class passvalues {

public PageReference Nagivatepage() {
obj=new PageReference('/apex/secondpage?var1=value1&var2=value2');
return null;
public PageReference obj;

public string value1{get;set;}
public string value2{get;set;}



2nd page:


<apex:page controller="class2">
<apex:outputLabel value="{!var1}"></apex:outputLabel>
<apex:outputLabel value="{!var2}"></apex:outputLabel>


2nd class:


public with sharing class class2 {


public string var1{get;set;}

public string var2{get;set;}




but this code is not working properly.....


please clarify that one its very urgent....