//"/MyMap" is the name of the mapping variable.
mapping = "/MyMap";
serviceFactory = createObject("java","coldfusion.server.ServiceFactory");
mappings = serviceFactory.runtimeService.getMappings();
//Shows all the mapping variables of the server before setting
//If the mapping variable is not present then create it
mappings["/MyMap"] = "Physical directory Path";//e.g-“D:\Project\myPath”
//Shows all the mapping variables of the server after setting
In above code my mapping variable name is "MyMap". I have created a service factory object to get the mapping structure. Using that structure we can check whether your mapping is present or not and if the mapping is not present you can also create one mapping as shown above.