<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic my arcgis js api submit a GP service request but 403 forbidden occurs in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/my-arcgis-js-api-submit-a-gp-service-request-but/m-p/566743#M52888</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,I encountered a thorny trouble,Now I publish a GP toolbox in the arcgis server in order that I can request GP service from the client browser.I use the "submitJob" method of esri.tasks.Geoprocessing object to request service.But unfortunately,my params exceed 2k character,so I have to use the proxy,I config the proxy.jsp and proxy.ashx,proxy.config according the arcgis js api help doc.But when I use the proxy.jsp as the proxy to submit the job,the firefox remindered that &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://localhost:8080/AgriService7.28/observationPlatform/proxy/proxy.jsp" rel="nofollow" target="_blank"&gt;http://localhost:8080/AgriService7.28/observationPlatform/proxy/proxy.jsp&lt;/A&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;A href="http://localhost:8399/arcgis/rest/services/IsosurfaceAnalyze/GPServer/IsosurfaceAnalyze/submitJob" rel="nofollow"&gt;http://localhost:8399/arcgis/rest/services/IsosurfaceAnalyze/GPServer/IsosurfaceAnalyze/submitJob&lt;/A&gt;&lt;SPAN&gt; 403 Forbidden"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;when I use the proxy.ashx,the firefox remindered that "SyntaxError: illegal XML character",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;when my params didn't exceed the limited characters ,I can succeed submitting the job,so I think the problem is my proxy configs,can anyone help me?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;below is my proxy.jsp(in the code I don't know how to find the token,so I don't add it):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;%@page session="false"%&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;%@page import="java.net.*,java.io.*" %&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;%!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;String[] serverUrls = {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; //"&amp;lt;url&amp;gt;[,&amp;lt;token&amp;gt;]"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; //For ex. (secured server): "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://myserver.mycompany.com/arcgis/rest/services,ayn2C2iPvqjeqWoXwV6rjmr43kyo23mhIPnXz2CEiMA6rVu0xR0St8gKsd0olv8a" rel="nofollow" target="_blank"&gt;http://myserver.mycompany.com/arcgis/rest/services,ayn2C2iPvqjeqWoXwV6rjmr43kyo23mhIPnXz2CEiMA6rVu0xR0St8gKsd0olv8a&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; //For ex. (non-secured server): "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://sampleserver1.arcgisonline.com/arcgis/rest/services" rel="nofollow" target="_blank"&gt;http://sampleserver1.arcgisonline.com/arcgis/rest/services&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://BILL:8399/arcgis/rest/services" rel="nofollow" target="_blank"&gt;http://BILL:8399/arcgis/rest/services&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://BILL:8399/arcgis/rest/services" rel="nofollow" target="_blank"&gt;http://BILL:8399/arcgis/rest/services&lt;/A&gt;&lt;SPAN&gt;" //NOTE - no comma after the last item&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;};&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;%&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; String reqUrl = request.getQueryString();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; boolean allowed = false;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; String token = null;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; for(String surl : serverUrls) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; String[] stokens = surl.split("\\s*,\\s*");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(reqUrl.toLowerCase().contains(stokens[0].toLowerCase())) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; allowed = true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(stokens.length &amp;gt;= 2 &amp;amp;&amp;amp; stokens[1].length() &amp;gt; 0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; token = stokens[1];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; break;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(!allowed) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; response.setStatus(403);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(token != null) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; reqUrl = reqUrl + (reqUrl.indexOf("?") &amp;gt; -1 ? "&amp;amp;" : "?") + "token=" + token;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; URL url = new URL(reqUrl);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; HttpURLConnection con = (HttpURLConnection)url.openConnection();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setDoOutput(true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setRequestMethod(request.getMethod());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(request.getContentType() != null) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setRequestProperty("Content-Type", request.getContentType());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setRequestProperty("Referer", request.getHeader("Referer"));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; int clength = request.getContentLength();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(clength &amp;gt; 0) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setDoInput(true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; InputStream istream = request.getInputStream();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; OutputStream os = con.getOutputStream();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; final int length = 5000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; byte[] bytes = new byte[length];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; int bytesRead = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; while ((bytesRead = istream.read(bytes, 0, length)) &amp;gt; 0) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; os.write(bytes, 0, bytesRead);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; else {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setRequestMethod("GET");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; out.clear();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; out = pageContext.pushBody();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; OutputStream ostream = response.getOutputStream();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; response.setContentType(con.getContentType());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; InputStream in = con.getInputStream();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; final int length = 5000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; byte[] bytes = new byte[length];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; int bytesRead = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; while ((bytesRead = in.read(bytes, 0, length)) &amp;gt; 0) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ostream.write(bytes, 0, bytesRead);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;} catch(Exception e) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; response.setStatus(500);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;below is the proxy.config:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;!-- Proxy config is used to set the ArcGIS Server services that the proxy will forward to.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; mustMatch: true to only proxy to sites listed, false to proxy to any site --&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;ProxyConfig mustMatch="false"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;serverUrls&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;!-- serverUrl options:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; url = location of the ArcGIS Server, either specific URL or stem&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll = true to forward any request beginning with the url&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; token = (optional) token to include for secured service&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; dynamicToken = if true, gets token dynamically with username and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; password stored in web.config file's appSettings section.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; --&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="http:/BILL:8399/arcgis/rest/services/" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true"&amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://sampleserver1.arcgisonline.com/arcgis/rest/services/" rel="nofollow" target="_blank"&gt;http://sampleserver1.arcgisonline.com/arcgis/rest/services/&lt;/A&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true"&amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://sampleserver2.arcgisonline.com/arcgis/rest/services/" rel="nofollow" target="_blank"&gt;http://sampleserver2.arcgisonline.com/arcgis/rest/services/&lt;/A&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; token=""&amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://server.arcgisonline.com/arcgis/rest/services/" rel="nofollow" target="_blank"&gt;http://server.arcgisonline.com/arcgis/rest/services/&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true"&amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://orthogonal.esri.com/arcgis/rest/services/" rel="nofollow" target="_blank"&gt;http://orthogonal.esri.com/arcgis/rest/services/&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true"&amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://hummer/ArcGIS/rest/services" rel="nofollow" target="_blank"&gt;http://hummer/ArcGIS/rest/services&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; dynamicToken="true"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;/serverUrls&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/ProxyConfig&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size:&amp;quot;7&amp;quot;;"&gt;notesï¼?I use arcgis 10&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 30 Jul 2011 00:42:06 GMT</pubDate>
    <dc:creator>billchuang</dc:creator>
    <dc:date>2011-07-30T00:42:06Z</dc:date>
    <item>
      <title>my arcgis js api submit a GP service request but 403 forbidden occurs</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/my-arcgis-js-api-submit-a-gp-service-request-but/m-p/566743#M52888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,I encountered a thorny trouble,Now I publish a GP toolbox in the arcgis server in order that I can request GP service from the client browser.I use the "submitJob" method of esri.tasks.Geoprocessing object to request service.But unfortunately,my params exceed 2k character,so I have to use the proxy,I config the proxy.jsp and proxy.ashx,proxy.config according the arcgis js api help doc.But when I use the proxy.jsp as the proxy to submit the job,the firefox remindered that &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://localhost:8080/AgriService7.28/observationPlatform/proxy/proxy.jsp" rel="nofollow" target="_blank"&gt;http://localhost:8080/AgriService7.28/observationPlatform/proxy/proxy.jsp&lt;/A&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;A href="http://localhost:8399/arcgis/rest/services/IsosurfaceAnalyze/GPServer/IsosurfaceAnalyze/submitJob" rel="nofollow"&gt;http://localhost:8399/arcgis/rest/services/IsosurfaceAnalyze/GPServer/IsosurfaceAnalyze/submitJob&lt;/A&gt;&lt;SPAN&gt; 403 Forbidden"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;when I use the proxy.ashx,the firefox remindered that "SyntaxError: illegal XML character",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;when my params didn't exceed the limited characters ,I can succeed submitting the job,so I think the problem is my proxy configs,can anyone help me?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;below is my proxy.jsp(in the code I don't know how to find the token,so I don't add it):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;%@page session="false"%&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;%@page import="java.net.*,java.io.*" %&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;%!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;String[] serverUrls = {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; //"&amp;lt;url&amp;gt;[,&amp;lt;token&amp;gt;]"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; //For ex. (secured server): "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://myserver.mycompany.com/arcgis/rest/services,ayn2C2iPvqjeqWoXwV6rjmr43kyo23mhIPnXz2CEiMA6rVu0xR0St8gKsd0olv8a" rel="nofollow" target="_blank"&gt;http://myserver.mycompany.com/arcgis/rest/services,ayn2C2iPvqjeqWoXwV6rjmr43kyo23mhIPnXz2CEiMA6rVu0xR0St8gKsd0olv8a&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; //For ex. (non-secured server): "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://sampleserver1.arcgisonline.com/arcgis/rest/services" rel="nofollow" target="_blank"&gt;http://sampleserver1.arcgisonline.com/arcgis/rest/services&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://BILL:8399/arcgis/rest/services" rel="nofollow" target="_blank"&gt;http://BILL:8399/arcgis/rest/services&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://BILL:8399/arcgis/rest/services" rel="nofollow" target="_blank"&gt;http://BILL:8399/arcgis/rest/services&lt;/A&gt;&lt;SPAN&gt;" //NOTE - no comma after the last item&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;};&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;%&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; String reqUrl = request.getQueryString();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; boolean allowed = false;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; String token = null;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; for(String surl : serverUrls) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; String[] stokens = surl.split("\\s*,\\s*");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(reqUrl.toLowerCase().contains(stokens[0].toLowerCase())) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; allowed = true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(stokens.length &amp;gt;= 2 &amp;amp;&amp;amp; stokens[1].length() &amp;gt; 0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; token = stokens[1];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; break;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(!allowed) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; response.setStatus(403);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(token != null) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; reqUrl = reqUrl + (reqUrl.indexOf("?") &amp;gt; -1 ? "&amp;amp;" : "?") + "token=" + token;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; URL url = new URL(reqUrl);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; HttpURLConnection con = (HttpURLConnection)url.openConnection();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setDoOutput(true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setRequestMethod(request.getMethod());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(request.getContentType() != null) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setRequestProperty("Content-Type", request.getContentType());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setRequestProperty("Referer", request.getHeader("Referer"));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; int clength = request.getContentLength();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if(clength &amp;gt; 0) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setDoInput(true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; InputStream istream = request.getInputStream();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; OutputStream os = con.getOutputStream();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; final int length = 5000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; byte[] bytes = new byte[length];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; int bytesRead = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; while ((bytesRead = istream.read(bytes, 0, length)) &amp;gt; 0) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; os.write(bytes, 0, bytesRead);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; else {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con.setRequestMethod("GET");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; out.clear();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; out = pageContext.pushBody();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; OutputStream ostream = response.getOutputStream();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; response.setContentType(con.getContentType());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; InputStream in = con.getInputStream();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; final int length = 5000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; byte[] bytes = new byte[length];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; int bytesRead = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; while ((bytesRead = in.read(bytes, 0, length)) &amp;gt; 0) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ostream.write(bytes, 0, bytesRead);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;} catch(Exception e) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; response.setStatus(500);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;below is the proxy.config:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;!-- Proxy config is used to set the ArcGIS Server services that the proxy will forward to.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; mustMatch: true to only proxy to sites listed, false to proxy to any site --&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;ProxyConfig mustMatch="false"&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;serverUrls&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;!-- serverUrl options:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; url = location of the ArcGIS Server, either specific URL or stem&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll = true to forward any request beginning with the url&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; token = (optional) token to include for secured service&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; dynamicToken = if true, gets token dynamically with username and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; password stored in web.config file's appSettings section.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; --&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="http:/BILL:8399/arcgis/rest/services/" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true"&amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://sampleserver1.arcgisonline.com/arcgis/rest/services/" rel="nofollow" target="_blank"&gt;http://sampleserver1.arcgisonline.com/arcgis/rest/services/&lt;/A&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true"&amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://sampleserver2.arcgisonline.com/arcgis/rest/services/" rel="nofollow" target="_blank"&gt;http://sampleserver2.arcgisonline.com/arcgis/rest/services/&lt;/A&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; token=""&amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://server.arcgisonline.com/arcgis/rest/services/" rel="nofollow" target="_blank"&gt;http://server.arcgisonline.com/arcgis/rest/services/&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true"&amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://orthogonal.esri.com/arcgis/rest/services/" rel="nofollow" target="_blank"&gt;http://orthogonal.esri.com/arcgis/rest/services/&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true"&amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; &amp;lt;serverUrl url="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://hummer/ArcGIS/rest/services" rel="nofollow" target="_blank"&gt;http://hummer/ArcGIS/rest/services&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; matchAll="true"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; dynamicToken="true"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;gt;&amp;lt;/serverUrl&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &amp;lt;/serverUrls&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/ProxyConfig&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size:&amp;quot;7&amp;quot;;"&gt;notesï¼?I use arcgis 10&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 Jul 2011 00:42:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/my-arcgis-js-api-submit-a-gp-service-request-but/m-p/566743#M52888</guid>
      <dc:creator>billchuang</dc:creator>
      <dc:date>2011-07-30T00:42:06Z</dc:date>
    </item>
  </channel>
</rss>

