How we can fetch url values in Apex class? code example

Example 1: How we can fetch url values in Apex class?

public with sharing class pageurlclass{
 
         /**
         * Webkul Software.
         *
         * @category  Webkul
         * @author    Webkul
         * @copyright Copyright (c) 2010-2016 Webkul Software Private Limited (https://webkul.com)
         * @license   https://store.webkul.com/license.html
         */
 
    public  String  headerdata{get;set;}
    public string urlvalue{get;set;}
    public string url{get;set;}
        
    public pageurlclass(){
        
         headerdata= ApexPages.currentPage().getHeaders().get('Host');
        
         urlvalue=Apexpages.currentPage().getUrl();
        
         url='https://' + headerdata+ urlvalue;
    }
  
 
}

Example 2: How we can fetch url values in Apex class?

<apex:page controller="pageurlclass">
 
   <!-- 
        /**
         * Webkul Software.
         *
         * @category  Webkul
         * @author    Webkul
         * @copyright Copyright (c) 2010-2016 Webkul Software Private Limited (https://webkul.com)
         * @license   https://store.webkul.com/license.html
         */
         -->
      
  1.  {!headerdata}
 
  2.  {!urlvalue}
 
  3.  {!url}
 
</apex:page>

Tags:

Misc Example