title: 302 Found Document has Moved error
body: <p>After reading various post from stackoverflow and some help from other guys I did authentication in my code and also trying to avoid the redirect that was occuring previously as I am new to all these things. I started getting the same error back of 302 Found, document has moved.</p>
  
  <p>I am trying to make a ajax call to other domain locally from my computer by writing some proxy code in jsp. And this is my jQuery AJAX code that is calling proxy.jsp page.</p>
  
  <pre><code>    var search_agile_metadata = 'https://search.xyz.com/ag/se/ag/get?id=';
  
  var on_show_info = function() {
                  //alert("aa");
      var outOfDomainAjaxCall = search_agile + current_doc_info.id;//An XML document
      alert(outOfDomainAjaxCall);
                  request_meta_info = $.ajax({
                  url: "proxy.jsp?url=" + outOfDomainAjaxCall,
                  type: 'GET',
                  success: on_get_metadata,
                  error: on_get_metadata_agile
  
          });
  </code></pre>
  
  <p>And my proxy.jsp file is:-</p>
  
  <pre><code>    &lt;%@ page language="java" import="org.apache.http.impl.client.AbstractHttpClient,
  org.apache.http.client.methods.HttpUriRequest,
  org.apache.http.client.methods.HttpGet,
  org.apache.http.protocol.HttpContext,
  org.apache.http.impl.client.DefaultHttpClient,
  org.apache.http.HttpResponse
  ,org.apache.http.HttpRequest,
  java.net.HttpURLConnection,
  java.net.URL,
  java.util.Collection,
  org.apache.commons.httpclient.HttpClient,
  org.w3c.dom.*,
  javax.xml.parsers.DocumentBuilder,
  javax.xml.parsers.DocumentBuilderFactory,
  java.net.*,
  java.io.*,
  org.apache.http.protocol.BasicHttpContext,
  org.apache.http.params.BasicHttpParams,
  org.apache.http.params.HttpParams,
  org.apache.http.Header,
  org.apache.http.client.params.HttpClientParams"
  contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  
  &lt;%
  String a_Url = request.getParameter( "url" ) ;
  
  URL url = new URL (a_Url);
  String encoding = new String(
           org.apache.commons.codec.binary.Base64.encodeBase64   
              (org.apache.commons.codec.binary.StringUtils.getBytesUtf8("test:test"))
            );
  
  
  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod("GET");
  connection.setDoOutput(true);
  connection.setFollowRedirects(false);
  connection.setRequestProperty  ("Authorization", "Basic " + encoding);
  InputStream content = (InputStream)connection.getInputStream();
  BufferedReader in   = 
      new BufferedReader (new InputStreamReader (content));
  String line;
  while ((line = in.readLine()) != null) {
     out.println(line);
  }
  
  %&gt;
  
  &lt;%
  final HttpParams params = new BasicHttpParams();
  HttpClientParams.setRedirecting(params, false);
  %&gt;
  </code></pre>
  
  <p>And when I get the response back from the server. I get this error. Any idea why I am getting this error back..</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
  &lt;html&gt;&lt;head&gt;
  &lt;title&gt;302 Found&lt;/title&gt;
  &lt;/head&gt;&lt;body&gt;
  &lt;h1&gt;Found&lt;/h1&gt;
  &lt;p&gt;The document has moved &lt;a href="https://ln.xyz.com/site/n/13000/smscc?TYPE=16777217&amp;amp;R"&gt;here&lt;/a&gt;.&lt;/p&gt;
  &lt;hr&gt;
  &lt;address&gt;Apache/2.0.58 (Unix) DAV/2 mod_jk/1.2.28 Server at search.xyz.com Port 80&lt;/address&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Any help will be appreciated..</p>