Get Visualforce page Name in Apex controller

How about:

String pageName = ApexPages.currentPage().getUrl().substringBetween('apex/', '?');

or, if you do not have parameters:

String pageName = ApexPages.currentPage().getUrl().substringAfter('apex/');

Check out the other String methods, there are lots to help in this regard.


Another solution

Use $CurrentPage.Name here

in VF page use

<input type="hidden" name="currentvfpage" value="{!$CurrentPage.Name}"/>

And in controller get the hidden input value

String pageName = ApexPages.currentPage().getParameters().get('currentvfpage');
system.debug('-----current page name----'+pageName);