<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style>
<!--
@font-face
        {font-family:Calibri}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif"}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
span.EmailStyle17
        {font-family:"Calibri","sans-serif";
        color:windowtext}
.MsoChpDefault
        {}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.WordSection1
        {}
-->
</style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I’m writing an application that accesses wms services on a variety of servers requiring the use of a proxy file. The application is running within Tomcat (v 6.0.18) and uses the jsp code at the bottom as the proxy. Everything works fine
for getcapabilities and getmap requests but when attempting a getfeatureinfo request I receive a java “no protocol” error. Can anyone provide a suggestion on correcting this? Thanks.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><b>GetFeatureInfo Code snippet:</b></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">info =
<span style="color:blue">new</span> OpenLayers.Control.WMSGetFeatureInfo({</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> title:
<span style="color:maroon">'Identify features by clicking'</span>,</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">
<span style="color:darkgreen">//drillDown: true,</span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> queryVisible:
<span style="color:blue">true</span>,</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> infoFormat:
<span style="color:maroon">'application/vnd.ogc.wms_xml'</span>,</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> eventListeners: {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> getfeatureinfo:
<span style="color:blue">function</span> (event) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> map.addPopup(<span style="color:blue">new</span> OpenLayers.Popup.FramedCloud(</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">
<span style="color:maroon">"chicken"</span>,</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> map.getLonLatFromPixel(event.xy),</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">
<span style="color:blue">null</span>,</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> event.text,</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">
<span style="color:blue">null</span>,</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">
<span style="color:blue">true</span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> ));</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> });</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> map.addControl(info);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> info.activate();</span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><b>Error Received:</b></p>
<p class="MsoNormal">java.net.MalformedURLException: no protocol: http://149.168.87.13/arcgis/services/NC1Map_Boundaries/MapServer/WMSServer?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&LAYERS=0,1,2,3&QUERY_LAYERS=0,1,2,3&STYLES=,,,&BBOX=-10624233.224628%2C3771371.436984%2C-7128920.79569%2C4585884.410277&FEATURE_COUNT=10&HEIGHT=333&WIDTH=1429&FORMAT=png&INFO_FORMAT=text%2Fhtml&SRS=EPSG%3A3857&X=758&Y=129
at java.net.URL.(Unknown Source) at java.net.URL.(Unknown Source) at java.net.URL.(Unknown Source) at org.apache.jsp.ncomOL.proxy_jsp._jspService(proxy_jsp.java:100) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source)
</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><b>JSP Proxy</b></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""><%@page session="false"%></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""><%@page import="java.net.*,java.io.*" %></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""><%!</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">String[] serverUrls = {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> //"<url>[,<token>]"</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> "http://sampleserver1.arcgisonline.com/arcgis/rest/services",</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> "http://sampleserver2.arcgisonline.com/arcgis/rest/services",
</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> "http://data.nconemap.com",</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> "http://149.168.87.16",</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> "http://149.168.87.16:8080",</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> "http://149.168.87.13",</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> "http://http://imagery.nconemap.com/ArcGIS/rest/services/",</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> "http://wms.jpl.nasa.gov/wms.cgi",</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> "http://demo.mapserver.org/cgi-bin/wms"</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">};</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">%></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""><%</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">try {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> String reqUrl = request.getQueryString();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> boolean allowed = true;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> String token = null;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> for(String surl : serverUrls) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> String[] stokens = surl.split("\\s*,\\s*");</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> System.out.println( "Evaluating date now" );</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> if(reqUrl.toLowerCase().contains(stokens[0].toLowerCase())) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> allowed = true;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> if(stokens.length >= 2 && stokens[1].length() > 0)</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> token = stokens[1];</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> break;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> </span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> if(!allowed) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> response.setStatus(403);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> return;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> if(token != null) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> reqUrl = reqUrl + (reqUrl.indexOf("?") > -1 ? "&" : "?") + "token=" + token;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> URL url = new URL(reqUrl);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> HttpURLConnection con = (HttpURLConnection)url.openConnection();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> con.setDoOutput(true);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> con.setRequestMethod(request.getMethod());</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> if(request.getContentType() != null) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> con.setRequestProperty("Content-Type", request.getContentType());</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> con.setRequestProperty("Referer", request.getHeader("Referer"));</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> int clength = request.getContentLength();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> if(clength > 0) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> con.setDoInput(true);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> InputStream istream = request.getInputStream();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> OutputStream os = con.getOutputStream();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> final int length = 5000;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> byte[] bytes = new byte[length];</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> int bytesRead = 0;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> while ((bytesRead = istream.read(bytes, 0, length)) > 0) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> os.write(bytes, 0, bytesRead);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> else {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> con.setRequestMethod("GET");</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> out.clear();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> out = pageContext.pushBody();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> OutputStream ostream = response.getOutputStream();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> response.setContentType(con.getContentType());</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> InputStream in = con.getInputStream();</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> final int length = 5000;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> byte[] bytes = new byte[length];</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> int bytesRead = 0;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> while ((bytesRead = in.read(bytes, 0, length)) > 0) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> ostream.write(bytes, 0, bytesRead);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> }</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">} catch(Exception e) {</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> response.setStatus(500);</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> // e.printStackTrace(response.getWriter());</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">}</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New"">%></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt; font-family:"Courier New""> </span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><b><span style="font-family:"Arial","sans-serif"; color:#0066FF">Brett Spivey</span></b></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Arial","sans-serif"; color:gray">NC OneMap Programmer</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Arial","sans-serif"; color:gray">Center for Geographic Information & Analysis</span></p>
<p class="MsoNormal"><span style="color:gray">Office of the State Chief Information Officer</span><span style="font-size:10.0pt; font-family:"Arial","sans-serif"; color:gray"></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Arial","sans-serif"; color:gray">919.754.6591</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Arial","sans-serif"; color:gray">brett.spivey@its.nc.gov</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Arial","sans-serif"; color:gray">http://www.cgia.state.nc.us</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Arial","sans-serif"; color:gray"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Arial","sans-serif"; color:gray">Email correspondence to and from this address may be subject to the North Carolina Public Records Law and may be disclosed to third parties by an authorized state
official.</span></p>
<p class="MsoNormal"> </p>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
E-mail correspondence to and from this address may be subject to the North Carolina Public Records Law and may be disclosed to third parties by an authorized state official.<br>
</font>
</body>
</html>