You need to sign in to do that
Don't have an account?

cookie class to retrieve cookie name from current page
Hi All,
I am writing a controller where i have a search field on VF page.when a text is entered in search area and clicked on search button , it looks for an existing cookie.If the cookie exist it goes to url A otherwise to url B.but when i used it in my page, the error is "System.NullPointerException: Attempt to de-reference a null object" .Please help me
My code :
public class searchingtest
{
public string searchtext{get;set;}
public PageReference searchbutton()
{
Cookie Name= ApexPages.currentPage().getCookies().get('Name');
String cname=Name.getName();
If(cname=='googlecompc_usen')
{
PageReference pageRef1 = new PageReference('http://www.google.com+searchtext');
pageRef1.setredirect(true);
return pageRef1;
}
else
{
PageReference pageRef2 = new PageReference('https://www.google.com');
pageRef2.setredirect(true);
return pageRef2;
}
}
}
Wherer do you get the error? In which line i mean? You should have an email in your inbox with more details.
Ignacio.
Hi,
I just need to know how to retrieve the current page cookie correctly .Can you please help me on this.
I think because i am not able to retrieve the current page cookie name correctly , i am getting this error.