• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Unable to get the content in URL

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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: http://google.com 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 132.200.13.2
it is set using setProperty method.
proxy server's port is 80

method 2)
passing arguement to "java" command

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

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


the program is as follows

import java.net.*;
import java.io.*;
import javax.swing.*;

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


public void getContent(){

System.setProperty("http.proxyHost","132.200.13.2");
System.setProperty("http.proxyPort","80");
String sa=System.getProperty("http.proxyHost");
System.out.println(sa);


try{
url=new URL(JOptionPane.showInputDialog("Enter url"));
BufferedInputStream is=new BufferedInputStream(url.openStream());
String s="";
while( is.available() != 0 ){
s+=(char)is.read();
}
System.out.println(s);
}
catch( MalformedURLException murle){
System.out.println("URL error!");
murle.printStackTrace();
System.exit(-1);
}
catch( IOException ioe){
ioe.printStackTrace();
System.out.println("IOError!");
System.exit(-1);
}
catch( Exception e){
e.printStackTrace();
System.out.println("Error!");
System.exit(-1);
}
}
}



output along with stack trace

132.200.13.2
java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at URLdemo.getContent(URLdemo.java:29)
at URLdemo.main(URLdemo.java:17)
IOError!
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not advanced Java. I'll move this to "Sockets and Internet Protocols."
 
Bartender
Posts: 9625
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please do not post the same question more than once. It causes confusion and duplication of effort as the community tries to help everyone.
 
bhagavatula indu sekhar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic