DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2005
    Posts
    97

    problem with reading from a website

    i have created a program that will read the source from a website and then do other things. however i cannot get my program to read from the website that i want to work with. all it returns is null, over and over.

    here is the part of code that i guess reads from the website.

    Code:
    if(buttonObj == searchButton)
    {			
    	try
    	{
    		String name = nameField.getText();
    		URL url = new URL("http://www.kingsofchaos.com/battlefield.php?jump=&search_type=s&search=" + name);
    		URLConnection connection = url.openConnection();
    		BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    				
    		// this isnt in my actual program but is just to show the output                		
                    for(int i = 0; i < 20; i++)
    		{
                            line = in.readLine();
    			System.out.println(line);
    		}						
    	}
    	catch(Exception e)
    	{
    		System.out.print(e);
    	}
    }
    when i change the url to:
    Code:
    URL url = new URL("http://www.yahoo.com");
    i get the actual source code which is what i want.

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    Your browser is probably saying this (on the javaconsole) :
    java.security.AccessControlException: access denied (java.net.SocketPermission www.db.no:80 connect,resolve)
    eschew obfuscation

  3. #3
    Join Date
    Dec 2005
    Posts
    97
    no...unless im doing the output wrong all i get is null, repeating.

  4. #4
    Join Date
    Mar 2004
    Posts
    635
    I checked the header and your status message is ok (200). I wonder if it has anything to do with the page being a php file? It shouldn't though.

  5. #5
    Join Date
    Dec 2005
    Posts
    97
    yea that what i was thinking, but then i tried another site that ended in .php and got the source code fine. someone suggested to me that i should try httpclient from apache. i would but i cant figure out how to make it work :P

Similar Threads

  1. Java Applet Compiler problem?
    By mdl in forum Java
    Replies: 3
    Last Post: 03-07-2005, 02:34 AM
  2. Reliability Problem
    By elise in forum Java
    Replies: 0
    Last Post: 10-30-2002, 04:40 AM
  3. Reading File in .NET
    By Sathya in forum .NET
    Replies: 3
    Last Post: 06-28-2002, 10:30 PM
  4. problem with recordset from Sybase and Oracle
    By substring in forum VB Classic
    Replies: 2
    Last Post: 07-24-2001, 02:29 PM
  5. Arabic problem view
    By Ayman in forum VB Classic
    Replies: 8
    Last Post: 04-03-2000, 08:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links