String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
1. Several methods of request:
request.getSchema() can return the protocol used by the current page, http or https;
request.getServerName() can return the name of the server where the current page is located;
request.getServerPort() can return the port used by the server where the current page is located, which is 80;
request.getContextPath() can return the name of the application where the current page is located;