RSS Forums RSS

URLConnection problem

Please support our Java advertiser: Programming Forums
Reply
Posts: 29
Reputation: claudiu_is is an unknown quantity at this point 
Solved Threads: 1
claudiu_is's Avatar
claudiu_is claudiu_is is offline Offline
Light Poster

Question URLConnection problem

  #1  
Oct 24th, 2007
I`m trying to compile a small program for authentication on a torrent site but when it reaches the setRequestProperty() line throws an exception:
Exception in thread "main" java.lang.IllegalStateException: Already connected
at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(Unknown Source)
at MovieCrawler.main(MovieCrawler.java:22)
I understand that something is already connected! How can I disconnect before using this method;
here is the code:

  1. import java.net.*;
  2. import java.io.*;
  3.  
  4.  
  5. public class MovieCrawler {
  6. public static void main(String[] args) throws Exception {
  7. URL url = new URL("http://www.torrentleech.org/login.php");
  8. URLConnection uCon = url.openConnection();
  9. BufferedReader in = new BufferedReader(new InputStreamReader(uCon.getInputStream()));
  10.  
  11. String inputLine;
  12. while ((inputLine = in.readLine()) != null)
  13. System.out.println(inputLine);
  14.  
  15. in.close();
  16. //for (int i=0;i<20;i++)
  17. // System.out.println(uCon.getHeaderFieldKey(i)+": "+uCon.getHeaderField(i));
  18. //System.out.println("kaaaaaaaaaaaaaa: "+uCon.getRequestProperty("Cookies"));
  19. String uspass = "***:***";
  20. uCon.setRequestProperty("Authorization","Basic"+uspass);
  21. uCon.connect();
  22. BufferedReader in2 = new BufferedReader(new InputStreamReader(uCon.getInputStream()));
  23. inputLine = "";
  24. while ((inputLine = in2.readLine()) != null)
  25. System.out.println(inputLine);
  26. in2.close();
  27. }
  28. }

pls help, I`ve spent several hours finding/creating an working authentication method... and this is my "greate" result
AddThis Social Bookmark Button
Reply With Quote  
Posts: 3,465
Reputation: peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold 
Solved Threads: 412
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: URLConnection problem

  #2  
Oct 24th, 2007
I consider rude to come here and ask for help on project for illigal activities.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the Java Forum
Views: 2325 | Replies: 1 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:42 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC