Note that there are some explanatory texts on larger screens.

plurals
  1. PO302 Found Error when Trying to get the contents of url using jsp
    primarykey
    data
    text
    <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/rest-services/services/ag/get?id='; var on_show_info = function() { var outOfDomainCall = search_agile_metadata + current_doc_info.id;//An XML document request_meta_info = $.ajax({ url: "proxy.jsp?url=" + outOfDomainCall , type: 'GET', success: on_get_metadata, error: on_get_metadata_agile }); }; var on_get_metadata = function(data, text_status, XMLHttpRequest) { console.log(data); } </code></pre> <p>Any my proxy.jsp file is:-</p> <pre><code> &lt;%@ page language="java" import="org.w3c.dom.*,javax.xml.parsers.DocumentBuilder,javax.xml.parsers.DocumentBuilderFactory,java.net.*,java.io.*" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt; &lt;% final String login ="user"; final String password ="pass"; Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication (login, password.toCharArray()); } }); String a_Url = request.getParameter( "url" ) ; String l_Content = "" ; if( a_Url!=null &amp;&amp; a_Url.length()&gt;0 ) l_Content = GetContent( a_Url ).toString() ; out.println( l_Content ); %&gt; &lt;%! StringBuffer GetContent( String a_Url ) throws Exception { URL l_URL = new URL(a_Url); BufferedReader l_Reader = new BufferedReader( new InputStreamReader( l_URL.openStream())); StringBuffer l_Result = new StringBuffer("") ; String l_InputLine = null ; while ((l_InputLine = l_Reader.readLine()) != null) //System.out.println("Print3" +l_InputLine ); l_Result.append( l_InputLine ); l_Reader.close(); return( l_Result ) ; } %&gt; </code></pre> <p>And When I get the response back from this proxy.jsp file, I get this error:-</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="HTTP://search.xyz.com/rest-services/se/agile/get?id=CD90"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt; </code></pre> <p>And if I check the status code in that above jQuery AJAX code then it is 200. So that means something is happening in the proxy.jsp page. Why it is not able to get the contents of url. Any suggestions will be appreciated...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload