ArcGIS API for JavaScript (4. x) 설정 에이전트

1. 프 록 시 경로 설정
require(["esri/config"], function(esriConfig) {
  esriConfig.request.proxyUrl = "localhost:8080/Java/proxy.jsp";//    
});

2proxy. jsp 에이전트


[,]"
  //For ex. (secured server): "http://myserver.mycompany.com/arcgis/rest/services,ayn2C2iPvqjeqWoXwV6rjmr43kyo23mhIPnXz2CEiMA6rVu0xR0St8gKsd0olv8a"
  //For ex. (non-secured server): "http://sampleserver1.arcgisonline.com/arcgis/rest/services"
  "http://sampleserver1.arcgisonline.com/arcgis/rest/services",
  "http://sampleserver2.arcgisonline.com/arcgis/rest/services",
  "http://sampleserver3.arcgisonline.com/arcgis/rest/services",
  "http://server.arcgisonline.com/ArcGIS/rest/services/",
  "http://maps1.arcgisonline.com",
  "http://www.tianditu.com/", 
};
%>
= 2 && stokens[1].length() > 0)
        token = stokens[1];
      break;
    }
  }
  allowed=true;
  if(!allowed) {
    response.setStatus(403);
    return;
  }
  if(token != null) {
    reqUrl = reqUrl + (reqUrl.indexOf("?") > -1 ? "&" : "?") + "token=" + token;
  }
  URL url = new URL(reqUrl);
	HttpURLConnection con = (HttpURLConnection)url.openConnection();
	con.setDoOutput(true);
	con.setRequestMethod(request.getMethod());
	if(request.getContentType() != null) {
	  con.setRequestProperty("Content-Type", request.getContentType());
	}
  con.setRequestProperty("Referer", request.getHeader("Referer"));
	int clength = request.getContentLength();
	if(clength > 0) {
		con.setDoInput(true);
		InputStream istream = request.getInputStream();
		OutputStream os = con.getOutputStream();
		final int length = 5000;
	  byte[] bytes = new byte[length];
	  int bytesRead = 0;
	  while ((bytesRead = istream.read(bytes, 0, length)) > 0) {
	    os.write(bytes, 0, bytesRead);
	  }
	}
  else {
    con.setRequestMethod("GET");
  }
	out.clear();
  out = pageContext.pushBody();
	OutputStream ostream = response.getOutputStream();
	response.setContentType(con.getContentType());
	InputStream in = con.getInputStream();
	final int length = 5000;
  byte[] bytes = new byte[length];
  int bytesRead = 0;
  while ((bytesRead = in.read(bytes, 0, length)) > 0) {
    ostream.write(bytes, 0, bytesRead);
  }
} catch(Exception e) {
	response.setStatus(500);
}
%>

좋은 웹페이지 즐겨찾기