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 6118653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:27:42+00:00 2026-05-23T15:27:42+00:00

I am Post ing some data into a specific URL by using the following

  • 0

I am Posting some data into a specific URL by using the following code:

import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;

public class LookupPOST {

public static void main(String[] args) throws Exception 
{
        String accountlookup = "<account>"+
                                "<name>N*</name>"+
                                "<type></type>"+
                                "<accountaddress>"+
                                    "<address></address>"+
                                    "<state></state>"+
                                    "<zip></zip>"+
                                    "<city></city>"+
                                    "<country></country>"+
                                    "<county></county>"+
                                "</accountaddress>"+
                               "</account>";

        URL url = new URL(" http://localhost:8080/Sfacgi/accounts/lookUpaccount");
        HttpURLConnection connection = (HttpURLConnection)url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("authenticate", "BBUSER1:BBUSER1");
        connection.setRequestProperty("Content-Type", "application/xml");
        connection.setRequestProperty("pinno", "2526121F96");
        connection.setRequestProperty("appversion", "BBV15");
        connection.setDoOutput(true);
        connection.setInstanceFollowRedirects(false);

         OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
         writer.write(accountlookup);
         writer.close();

         if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) 
         {
             System.out.println(" Success ");
         } 
         else 
         {
             System.out.println("Server returned HTTP error code :"+connection.getResponseCode());
         }

}}

It sucessfully posts, but when I retrieve the data, it gives me the following error:

Excpetion = java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/Sfacgi/accounts/lookUpaccount
java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:88080/Sfacgi/accounts/lookUpaccount
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1403)
at com.jp.look.LookupGet.main(LookupGet.java:31)

I am using the following code:

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class LookupGet 
{

    public static void main(String[] args) throws Exception 
{   
    try
    {
        URL url = new URL("http://localhost:8080/Sfacgi/accounts/lookUpaccount");
        HttpURLConnection connection = (HttpURLConnection)url.openConnection();
        connection.setRequestMethod("GET");
        connection.setRequestProperty("authenticate", "BBUSER1:BBUSER1");
        connection.setRequestProperty("Content-Type", "application/xml");
        connection.setRequestProperty("pinno", "2526121F96");
        connection.setRequestProperty("appversion", "BBV15");
        connection.setDoOutput(true);
        connection.setInstanceFollowRedirects(false);
        int timeoutMs=500000;
        connection.setConnectTimeout(timeoutMs);
        connection.setReadTimeout(timeoutMs);

        //InputStream is = url.openStream();

        InputStream is1 = connection.getInputStream();

        BufferedReader reader = new BufferedReader(new InputStreamReader(is1));

            String data;

            while ((data = reader.readLine()) != null) 
            {
                 System.out.println(data);
            }
            reader.close();

    }
    catch(Exception e)
    {
        System.out.println(" Excpetion = " + e);
        e.printStackTrace();        
    }
}}

Can anyone tell me where I am wrong in my code? Any suggestions.

  • 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-23T15:27:42+00:00Added an answer on May 23, 2026 at 3:27 pm
    1. Localhost is accessible as you are able to do the post call.
    2. The error code 500 indicates that your sever is not able to handle the request, due to any reason. main be some exception or URL is not mapped.
    3. Incase of exception read the ErrorStream method instead of Inputstream to know about the error
      Example
      connection.getErrorStream()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am posting some data using ajax. I want to manipulate that data and
I'm posting data to a page called process.aspx that handles some business logic with
I am POSTING some data from an IPhone application want want to be able
So the following jQuery is posting some values to a PHP script and getting
I have logged into a website by posting data with curl. I now want
I'm having some problems posting JSON data to my rails controller and getting the
I'm having some problems posting multiple parameters to my controller using AJAX. Both parameters
Can I get some help posting across different pages from a custom control? I've
Posting a stack overflow question on stackoverflow.com, how amusing :-) I'm running some recursive
I have been posting on my blog http://www.prashantraju.com/ since Jan 2010 however for some

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.