UrlConnection does not support output

by Hershiv Haria » Mon, 07 Dec 2009 13:55:58 GMT

Sponsored Links
 Hi all,

I'm currently trying to get an Android application to connect and send
a protocol buffer to a servlet on App Engine.
However, when I get to the line "OutputStream out =
urlc.getOutputStream()" I get the exception that it "does not support

I've not found many people with this issue, and no posted fixes apart
from using newer SDKs. However, this is for a university project and
I'm sticking to 1.5, so any help would be appreciated.

The only other relevant information I can think of is I have added the
uses internet permission, again I'm on SDK1.5 and I'm running in

The code is as follows:

package my.transferclient;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;

import my.tft.protos.RandomMessageProtos.Note;
import my.tft.protos.RandomMessageProtos.RandomMessage;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class TransferClient extends Activity {

        private final static String TAG = "TransferClient";
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        try {
        URL url = new URL(" :8080/testfileupload");
        URLConnection urlc = url.openConnection();

        OutputStream out = urlc.getOutputStream();

        RandomMessage.Builder rm = RandomMessage.newBuilder();
        Note.Builder note = Note.newBuilder();

        note.setName("Blargy McBlarg");
        note.setMessage("This is a random message");



        BufferedReader rd = new BufferedReader(new InputStreamReader
                String line;
                System.out.println("Respose is:");
                while ((line = rd.readLine()) != null) {

        } catch (Exception e) {
                Log.v(TAG, e.getMessage());
        } // catch