Hi,

I am trying to work around a CORS issue on my app server side by standing up a 
proxy jsp in order to talk to Solr directly.  It's really just a request 
forwarder at this point in time.  The problem is that the same query I run 
through the proxy works fine through the browser, but when I run it in the 
proxy it always returns a 400.

I've tried to do some initial research, but I am coming up empty.  Can any one 
please shed some light on the situation?

Some code snippets:
JS XMLHTTPReq call:
var queryStr = '(Line1:Tom OR Line2:Tom OR Line3:Tom)';
...
var dataUrl = 'http://[snip!]:8983/solr/[snip!]/query?&q=' + queryStr + 
'&fl=Field0, Field1+, Line2, Line3, Line4, Line5, Line6, Line7, Field8, Field9, 
Field10 ...';

var strURL = 'proxy.jsp?dataUrl=' + encodeURIComponent(dataUrl);
    var xmlHttpReq = false;
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttpReq.open('GET', strURL, true);
    xmlHttpReq.setRequestHeader('Content-Type', 
'application/x-www-form-urlencoded');
    xmlHttpReq.onreadystatechange = function() {
        if (xmlHttpReq.readyState == 4) {
            var temp = xmlHttpReq.responseText;
            var refinedData = JSON.stringify(JSON.parse(temp).response.docs);

And the proxy call:
String dataUrl = request.getParameter("dataUrl");
      dataUrl = URLDecoder.decode(dataUrl);
      URL obj = new URL(dataUrl);
      HttpURLConnection con = (HttpURLConnection) obj.openConnection();

      // optional default is GET
      con.setRequestMethod("GET");
      con.setDoOutput(true);
      con.setRequestProperty("Accept", "application/json");

      int responseCode = con.getResponseCode();

I'm not sure why exactly this call is failing with a 400.  Any help that could 
be provided would be welcomed.

Thanks in advance!

-Mark
[GrayHair]
GHS Confidentiality Notice

This e-mail message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized review, use, disclosure or distribution of this information is 
prohibited, and may be punishable by law. If this was sent to you in error, 
please notify the sender by reply e-mail and destroy all copies of the original 
message.

GrayHair Software <http://www.grayhairSoftware.com>

Reply via email to