ApexPages.currentPage().getUrl()

ApexPages.currentPage().getUrl() is used to give the information after the HOST URL.

Sample Code:


Visualforce page:

<apex:page controller=”Sample”>
    <apex:form >
        <apex:pageBlock >
            Current URL is {!currentURL}
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Class:

public with sharing class Sample {
    
    public String currentURL {get;set;}
    
    public Sample() {
        currentURL = ApexPages.currentPage().getUrl();
    }
        
}


Output:



Cheers!!!

Leave a Reply