Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with Apache HttpClient  RSS feed

Samuel Goldschmidt
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a strange problem here with my application.
What the application should do: Download the source code of web pages and save them to a local file.
To do this, I use the Apache httpclient library.

My problem:
The downloader is a Swing application created with NetBeans and its GUI Builder.
To download the web page, some lines of code using httpclient are needed.
When the "Start download" button is pressed, the page should be downloaded.
It's just, if I just put the download code in the ActionListener.actionPerformed(...) method of the "Start download" button (which is called when the button is pressed), it doesn't work! The thread just stops mid-flow! On the other hand, if I download something using HttpClient before the Swing application even starts, everything works fine afterwards if the button is pressed! Why does some random code completely detached from the main application influence the result of the latter?

I'm not asking you to solve my problem (but any help would be GREATLY appreciated!). But could you just try out the application for yourself and see if you can replicate the error? I attached a zip file (just rename it to to this post containing two folders, which are two NetBeans projects. To build and execute them, you need the following libs (they are very small!): (add commons-httpclient-3.1.jar to your libs) (add commons-logging-1.1.1.jar to your libs) (add commons-codec-1.3.jar to your libs).

If you aren't behind a proxy, comment out the lines in following the
// Comment the next section (3 lines) out if you don't sit behind a proxy

If you would like to investigate further, please look inside . The thread hangs after the comment.

Any help appreciated! Thanks in advance,
Ulf Dittmer
Posts: 42972
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

I have deleted the attachment you posted, since we don't want to host zip files of unknown content. Masquerading it as a .jpg file to circumvent the restriction to image files is not a really nice thing to do.

If you have a short code section you can post it here. If you can't shorten it down for some reason then you need to find some other place to make it public; you can then link to it from your post here.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!