Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7528975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:31:56+00:00 2026-05-30T04:31:56+00:00

I have been dealing with a problem for some time and would really appreciate

  • 0

I have been dealing with a problem for some time and would really appreciate it if somebody can give me some pointers.

I basically have to perform an ajax call to an aspx page on another server. In IE8 this does not work due to cross-domain problems. Some people suggested I tried jquery’s datatype “jsonp” and that doing so is going to allow cross-domain communication in IE8 but it failed.

So, in order to solve that problem, I have a browser detection routine in my code that checks if it is IE8. If it is IE8 what I do is that I do an ajax call to an interim jsp page.

What the interim jsp page is supposed to do, is take those parameters and basically post them to an aspx page.

Regarding this this is the code I am using:

<%

// get the parameters
String fileName = request.getParameter("fileName");
String param02 = request.getParameter("param02");
String param03 = request.getParameter("param03");
String param05 = request.getParameter("param05");
String param08 = request.getParameter("param08");
String param11 = request.getParameter("param11");


java.net.URL url;
java.net.HttpURLConnection connection = null;  
try {

    String urlParameters = "fileName="+ fileName+"&param02="+ param02+"&param03="+ param03+"&param05="+ param05+"&param08="+ param08+"&param11="+ param11;
    String encodedurl = java.net.URLEncoder.encode(urlParameters); 

    out.println(encodedurl);
    //Create connection
    url = new java.net.URL(
            "https://somepage.aspx");
    connection = (java.net.HttpURLConnection) url
            .openConnection();
    connection.setRequestMethod("POST");
    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    ////connection.setRequestProperty("Content-Type","text/xml; charset=utf-8");

    connection.setRequestProperty("Content-Length", "" + 
            Integer.toString(encodedurl.getBytes().length));
    connection.setRequestProperty("Content-Language", "en-US");  

    connection.setUseCaches (false);
    connection.setDoInput(true);
    connection.setDoOutput(true);

    //Send request
    DataOutputStream wr = new DataOutputStream (
            connection.getOutputStream ());
    wr.writeBytes (encodedurl);
    wr.flush ();
    wr.close ();
out.println(connection.getResponseCode());

    //Get Response

      InputStream is = connection.getInputStream();
      BufferedReader rd = new BufferedReader(new InputStreamReader(is));
      String line;
      StringBuffer responseBuffer = new StringBuffer(); 
      while((line = rd.readLine()) != null) {
        responseBuffer.append(line);
        responseBuffer.append('\r');
      }
      rd.close();
      out.println("\n\nRESPONSE\n\n" +responseBuffer.toString());
      out.println(connection.getErrorStream());



} catch (Exception e) {

    e.printStackTrace();
    out.println("Exception :(+ " +e);


} finally {

    if(connection != null) {
        connection.disconnect(); 
    }
}

    %>

The code results with the following error:

java.io.IOException: Server returned HTTP response code: 500 

When in chrome, the normal ajax call is performed and that works – nothing similar to this error code.

Can anybody please help out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:31:58+00:00Added an answer on May 30, 2026 at 4:31 am

    The server has crashed. The connection.getErrorStream() may contain a detailed error report. You need to read it in the catch block.

    As to your code, at least the way how you URL encoded the query string is not right.

    String urlParameters = "fileName="+ fileName+"&param02="+ param02+"&param03="+ param03+"&param05="+ param05+"&param08="+ param08+"&param11="+ param11;
    String encodedurl = java.net.URLEncoder.encode(urlParameters); 
    

    You should not URL encode the separator characters & and = at all. Fix it as follows:

    String charset = "UTF-8";
    String urlParameters = String.format(
        "fileName=%s&param02=%s&param03=%s&param05=%s&param08=%s&param11=%s", 
            URLEncoder.encode(fileName, charset), 
            URLEncoder.encode(param02, charset), 
            URLEncoder.encode(param03, charset), 
            URLEncoder.encode(param05, charset), 
            URLEncoder.encode(param08, charset),
            URLEncoder.encode(param11, charset));
    

    You should also be extremely careful with using the charset. You’re relying on the platform default charset all the time instead of explicitly specifying it. The server may not necessarily use the same platform default charset. The content length for example may vary depending on the charset used.

    You should also not be using the DataOutputStream to write the request body. It’s intented for creating so-called .dat files where data blocks are formatted and separated in a special manner at binary level. Just write it straight to the connection.getOutputStream().

    connection.getOutputStream().write(urlParameters.getBytes(charset));
    

    That the server has crashed instead of returning some HTTP 4nn error in turn also indicates a programming bug in the server’s code. If you have control over this, fix that as well. If not, report it to the responsible server admin.

    See also:

    • Using java.net.URLConnection to fire and handle HTTP requests
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been dealing with this problem for quite some time. What I am trying
I have been dealing many days with a problem without any success. In my
I have been dealing with Nasm and GNU C inline asm on a Linux
I have this code I been working on but I'm having a hard time
I have been dealing with FTP lately and I'm not sure about the security
We have been dealing with a lot of headaches in development and support. Tickets
I have been using the ASP.NET AJAX UpdatePanel control a lot lately for some
Have been looking at the MVC storefront and see that IQueryable is returned from
Have been studying the file system related classes of Adobe AIR 1.5, but so
Have been struggling with Javascript closure for a while trying to wrap brain around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.