Using this tip we can add mapping variables to the coldfusion server dynamically as follows.
//"/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
Here the variable “mapping” contains the name of the mapping. By creating an object of Java type of coldfusion server we are accessing the coldfusion server services and mapping is also a part of it and it is stored in the structure “mappings” .So by accessing that structure we can know whether the mapping is defined or not and by using that structure we can also create a new mapping as shown above.