File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Unable to get the content in URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Unable to get the content in URL" Watch "Unable to get the content in URL" New topic

Unable to get the content in URL

bhagavatula indu sekhar
Ranch Hand

Joined: Sep 17, 2006
Posts: 34
the program written is working at home but not in college.

the program takes in a URL of a web-page as input.
the program is expected to retrieve the content of a web-page which is then further analysed to find the emailids present in that web-page.

the web-pages present on the local hard disk are retrieved properly but when the URL is over Internet ex: it is not working.

the college provides us Internet Service through a proxy server.
we are working on JDK6.0 kit and Windows XP SP2 Operating System.we are developing this application under eclipse2.0 IDE tool.
the college system has Pentium processor and 256MB RAM.

can you please help me in solving this problem?

Proxy Server settings :

method 1)
proxy server's address is
it is set using setProperty method.
proxy server's port is 80

method 2)
passing arguement to "java" command

java -Dhttp.proxyHost= -Dhttp.proxyPort=80 URLdemo

when either of the one is used the message i am getting error

the program is as follows

import javax.swing.*;

public class URLdemo {
URL url;
public static void main(String[] args) {
URLdemo ur=new URLdemo();

public void getContent(){

String sa=System.getProperty("http.proxyHost");

url=new URL(JOptionPane.showInputDialog("Enter url"));
BufferedInputStream is=new BufferedInputStream(url.openStream());
String s="";
while( is.available() != 0 ){
catch( MalformedURLException murle){
System.out.println("URL error!");
catch( IOException ioe){
catch( Exception e){

output along with stack trace Unexpected end of file from server
at Source)
at Source)
at Source)
at Source)
at Source)
at URLdemo.getContent(
at URLdemo.main(
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Not advanced Java. I'll move this to "Sockets and Internet Protocols."

[Jess in Action][AskingGoodQuestions]
Joe Ess

Joined: Oct 29, 2001
Posts: 9188

Please do not post the same question more than once. It causes confusion and duplication of effort as the community tries to help everyone.

[How To Ask Questions On JavaRanch]
bhagavatula indu sekhar
Ranch Hand

Joined: Sep 17, 2006
Posts: 34
i am sorry Joe Ess.
i will make sure that it will never happen again.
i will continue the dialog using the previous post itself

"problem with proxy server".
I agree. Here's the link:
subject: Unable to get the content in URL
jQuery in Action, 3rd edition