When we use ArcGIS API for JavaScript to query the ArcGIS service, if the parameters of the query are long, the result will not be queried by the Get method, because the parameters submitted by the Get method have a length limit and need to be proxied to use the post submission.
ArcGIS provides a solution that is proxy.jsp.
First introduce the PROXY.JSP:ESRICONFIG.DEFAULTS.IO.PROXYURL=HTTP://SERVERNAME:PROT/ARCGIS_JS_API/PROXY.JSP introduction proxy page in the project page JS
Esriconfig.defaults.io.alwaysuseproxy=true; Sets whether the agent has been working
After introduction, put the proxy.jsp into the project.
Agent page source code as follows:
<% @page session= "false"%><% @page import= "java.net.*,java.io.*"%><%! String[] Serverurls = {"Http://servername:8399/arcgis/rest/services"//For what services work, you can configure multiple with "," split. };try {String Requrl = request.getquerystring (); Boolean allowed = false; String token = null; for (String surl:serverurls) {string[] Stokens = Surl.split ("\\s*,\\s*"); if (Requrl.tolowercase (). Contains (Stokens[0].tolowercase ())) {allowed = true; if (stokens.length >= 2 && stokens[1].length () > 0) token = stokens[1]; Break }} if (Requrl.endswith (". png")) 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 b Ytesread = 0;while ((bytesread = in.read (bytes, 0, length)) > 0) {ostream.write (bytes, 0, byte)sread);}} catch (Exception e) {response.setstatus (500);} %>
Using proxy.jsp in ArcGIS API for JavaScript