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

  • Home
  • SEARCH
  • 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 6580659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:03:20+00:00 2026-05-25T16:03:20+00:00

My application gets most of its data from a php web server. My problem

  • 0

My application gets most of its data from a php web server.

My problem is when the server return errors.
The errors are not HTML pages, but simple strings.
for example:

ERROR001

could stand for invalid name.

here is my code:

String responseBody = null;
URL url = new URL(strUrl);
URLConnection connection;
connection = url.openConnection();
connection.setUseCaches(false);
InputStream isResponse = (InputStream) connection.getContent(); // on errors I get IOException here
responseBody = convertStreamToString (isResponse);

When I use it, I get IOException on connection.getContent();

I also tried:

HttpGet getMethod = new HttpGet(url);
String responseBody = null;
responseBody = mClient.execute(getMethod,mResponseHandler); // on errors I getClientProtocolException

but I get getClientProtocolException on mClient.execute

Any ideas how I could read a result like ERROR001 into a string?

  • 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-25T16:03:21+00:00Added an answer on May 25, 2026 at 4:03 pm

    The problem is that on error, the Http header is HTTP Error 500 (Internal server error).
    To read the error content I used the following code:

        String responseBody = null;
        URL url = new URL(strUrl);
        HttpURLConnection connection;
        connection = (HttpURLConnection) url.openConnection();
        connection.setUseCaches(false);
        InputStream isResponse = null;
        try {
            isResponse = connection.getInputStream();
        } catch (IOException e) {
            isResponse = connection.getErrorStream();
        }
        responseBody = convertStreamToString (isResponse);
    
        return responseBody;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a web application that gets its data from a certain database. The
I'm developing an application that gets large images from an Internet server which is
My application is running on Google App Engine and most of requests constantly gets
I'm making an application which uses MANY images. The application gets the images from
I'm working on an application that gets content from feeds in C#. This content
I'm writing a web application (in Python, not that it matters). One of the
I write a client-server application which will be sending an .xml file from the
I'm finding myself hardcoding html into C#. It's usually on a data-driven pages. The
I'm working on an application that needs to accept posted data from a form
I am working on an application that gets text from a text file on

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.