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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:49:36+00:00 2026-05-23T10:49:36+00:00

I am a bit green with Java but I have ran into an issue

  • 0

I am a bit green with Java but I have ran into an issue when trying to UPLOAD a local file to a remote FTP server through a SQUID HTTP proxy (please note this obviously ties my hands so that ‘FTP’ and ‘SOCKS’ proxy types are not in scope).

So here is my code:

                       URL url = new URL(urlString);
                       OutputStream os ;                             

                       System.setProperty("proxySet", "true");
                       System.setProperty("proxyHost", proxyHost.trim());
                       System.setProperty("proxyPort", proxyPort.stringValue());


                       URLConnection ftpConn = url.openConnection() ;
                       ftpConn.setAllowUserInteraction(true); //threw this in to see if it would work, does nothing
                       ftpConn.setDoOutput(true); //here is where I set the setDoOutput
                       os = ftpConn.getOutputStream(); //here is where the exception occurs

I keep getting this exception:

Java call terminated by uncaught Java
exception: java.net.ProtocolException:
cannot write to a URLConnection if
doOutput=false – call
setDoOutput(true)

So I have tried this with an FTPURLConnection etc and have had the same issue.

When debugging this, it appears that there are no less than THREE variables that are called doOutput within the ftpConn.
Only one is editable (whereas the other two are not)

The first one (and it seems the one that is returned via the getDoOutput) returns true after the setting of the ftpConn.setDoOutput(true);.

looking over the source code for HttpURLConnection:

 public synchronized OutputStream getOutputStream()
                    throws IOException {

                try {
                    if (!doOutput) {
                        throw new ProtocolException(
                                "cannot write to a URLConnection"
                                        + " if doOutput=false - call setDoOutput(true)");
                    }

Looking over the Proxy handling in FtpURLConnection leads me to believe that when it determines that you are using an HTTP Proxy it passes off the the processing to the HttpURLConnection.

This is where I think the disconnect is happening (either for me or the library or the proxy).

Am I missing someway to set the setDoOutput or something else?

I have been able to successfully tunnel out of the proxy for GETs, but PUTs are all FAILING on the doOutput.

Thanks for any help or pointers to get this to work.

P.S.
I am using Java 1.5.0_10 (we are here to remain consistent with other applications)

  • 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-23T10:49:37+00:00Added an answer on May 23, 2026 at 10:49 am

    well found out this is a bug (Bug 6519647) in metalink. the workaround is pretty much use something different!

    (this bug persists no matter how the proxy is set (with/wihtout the “http.” and even via the proxy class)

    sorry for the duplicate edit/answer, this is my first ‘answer’ to my own question.

    switched over the ftp4j but still running into squid proxy issues (which is a whole different story).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Bit confused here, I have an on-demand instance but do I get charged even
In Windows Vista & 7 progressbars are green and have a glassy finish. But
Ok so I have a bit o' script that works in FF but not
Bit of an obscure one this. My setup is all running on my local
Bit of a strange question here i know. but i wanted to know if
Bit support question. Apologies for that. I have an application linked with GNU readline.
Bit of a philosophical question. If you have a public website with a site
Bit of an odd question but is there a way of seeing what objects
Bit of a bizarre question, but does anyone know the actual limit to the
Bit of a beginner question here: Say I have a block of xml: <root>

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.