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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:57:40+00:00 2026-06-07T08:57:40+00:00

I am sending value through using HTTP-post but an exception occur my code is

  • 0

I am sending value through using HTTP-post but an exception occur my code is as:-

public static InputStream SendDetails(String senderEmail,String senderName,String senderPhone,String comment )
{
     if(item != null)
        {
            url = constants.STATEURL + item.getListingid().toString()+"/contact";//?access_token=0|V1CALGARY|e98984a4c954fa1d78e3be626ad81a1d&mode=map";
        }
        else if(itemsavedfromdb != null)
        {
            url = constants.STATEURL + itemsavedfromdb.getListingid().toString()+"/contact";//?access_token=0|V1CALGARY|e98984a4c954fa1d78e3be626ad81a1d&mode=map";
        }
        else if(itemrecentfromdb != null)
        {
            url = constants.STATEURL + itemrecentfromdb.getListingid().toString()+"/contact";//?access_token=0|V1CALGARY|e98984a4c954fa1d78e3be626ad81a1d&mode=map";
        }

        List<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("access_token",constants.accesstokenstate));

        nameValuePairs.add(new BasicNameValuePair("mode","map"));

        nameValuePairs.add(new BasicNameValuePair("senderEmail",senderEmail));

        nameValuePairs.add(new BasicNameValuePair("senderName",senderName));

        nameValuePairs.add(new BasicNameValuePair("senderPhone",senderPhone));

        nameValuePairs.add(new BasicNameValuePair("comment",comment));  

        HttpPost request = new HttpPost(url);
        request.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpClient client = new DefaultHttpClient();
        HttpResponse response = client.execute(request);

        return response.getEntity().getContent();

}
this method called by as:-

            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
            mailHandler myhandler = new mailHandler();
            xr.setContentHandler(myhandler);
            String mailID = youremail.getText().toString();

            if(mailID != null && !mailID.equalsIgnoreCase("") )
             {
               System.out.println("1");
               ios = SendDetails(mailID,yourName.getText().toString(),yourPhoneNo.getText().toString(),yourMessage.getText().toString());   
               System.out.println("ios-----"+ios);
               String strResponse = convertStreamToString(ios);
                   System.out.println("response"+strResponse);                 
               xr.parse(new InputSource(ios));

                resultmail = myhandler.emailresultdata();

                customizeDialog = new CustomizeDialog(PropertyDetail.this);  
                customizeDialog.setTitle("Success");  
                customizeDialog.setMessage("Email send successfully");  
                customizeDialog.show();

Excepion occure above code due to which data not successfully send

follwing is stacktrace:-

07-03 09:02:15.264: WARN/System.err(491): java.io.IOException: Attempted read on closed stream.
07-03 09:02:15.275: WARN/System.err(491):     at org.apache.http.conn.EofSensorInputStream.isReadAllowed(EofSensorInputStream.java:127)
   07-03 09:02:15.275: WARN/System.err(491):     at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:176)
   07-03 09:02:15.275: WARN/System.err(491):     at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:516)
   07-03 09:02:15.275: WARN/System.err(491):     at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:479)
   07-03 09:02:15.275: WARN/System.err(491):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:318)
   07-03 09:02:15.275: WARN/System.err(491):     at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:275)
   07-03 09:02:15.275: WARN/System.err(491):     at com.rentfaster.home.PropertyDetail.onClick(PropertyDetail.java:1623)
   07-03 09:02:15.275: WARN/System.err(491):     at java.lang.reflect.Method.invokeNative(Native  Method)
   07-03 09:02:15.275: WARN/System.err(491):     at java.lang.reflect.Method.invoke(Method.java:507)
    07-03 09:02:15.275: WARN/System.err(491):     at android.view.View$1.onClick(View.java:2139)
    07-03 09:02:15.284: WARN/System.err(491):     at android.view.View.performClick(View.java:2485)
    07-03 09:02:15.284: WARN/System.err(491):     at android.view.View$PerformClick.run(View.java:9080)
    07-03 09:02:15.284: WARN/System.err(491):     at android.os.Handler.handleCallback(Handler.java:587)
    07-03 09:02:15.284: WARN/System.err(491):     at android.os.Handler.dispatchMessage(Handler.java:92)
    07-03 09:02:15.284: WARN/System.err(491):     at android.os.Looper.loop(Looper.java:130)
     07-03 09:02:15.284: WARN/System.err(491):     at android.app.ActivityThread.main(ActivityThread.java:3683)
   07-03 09:02:15.284: WARN/System.err(491):     at java.lang.reflect.Method.invokeNative(Native Method)
   07-03 09:02:15.284: WARN/System.err(491):     at java.lang.reflect.Method.invoke(Method.java:507)
   07-03 09:02:15.284: WARN/System.err(491):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   07-03 09:02:15.294: WARN/System.err(491):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   07-03 09:02:15.294: WARN/System.err(491):     at dalvik.system.NativeStart.main(Native Method)

and my convertStreamToString methos is as:-

private static String convertStreamToString(InputStream is) {

    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    StringBuilder sb = new StringBuilder();

    String line = null;
    try {
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return sb.toString();
}

Any one suggest me where am I wrong and what’s right way to do this.

  • 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-06-07T08:57:42+00:00Added an answer on June 7, 2026 at 8:57 am

    Ok , change your code from

    xr.parse(new InputSource(ios));
    

    to

    InputStream input = new ByteArrayInputStream(strResponse.getBytes());
    xr.parse(new InputSource(input));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sending an email through Outlook using VB.Net code. The syntax for creating
i am sending email through my application using the following code of c# myMail.Body
sending mail along with embedded image using asp.net I have already used following but
I regularly use a standard form to send login information through the HTTP POST
I am sending a post using NSURLRequest. NSURL *url = [NSURL URLWithString:someUrlString]; NSMutableURLRequest *theRequest
How do I send AJAX data through $.ajax() in JavaScript via type: POST using
sending text to label and number to int from tabelview to viewcontroller but it
Sending Email in Android using JavaMail API without using the default/built-in app I'm trying
Im sending (with ASIFormDataRequest) a POST request, with 4 parameters. The server launches a
From a webpage, I need to send JSON data using POST method to a

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.