I want to read content of the web site through java program. I am using HttpURLConnection class. But I am unable to view the contents. I got code from net "Html source viewer". But what if website is in php, jsp etc. Any pointers ??
Reading the content of a web page could be as simple as:
It doesn't matter whether the web site is written in JSP, PHP or Fortran, because either way you're going to get HTML delivered back to you. [ March 22, 2007: Message edited by: Ulf Dittmer ]
Solution given by you is not working. See the stack trace below : java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.Socket.connect(Socket.java:507) at java.net.Socket.connect(Socket.java:457) at sun.net.NetworkClient.doConnect(NetworkClient.java:157) at sun.net.www.http.HttpClient.openServer(HttpClient.java:365) at sun.net.www.http.HttpClient.openServer(HttpClient.java:477) at sun.net.www.http.HttpClient.<init>(HttpClient.java:214) at sun.net.www.http.HttpClient.New(HttpClient.java:287) at sun.net.www.http.HttpClient.New(HttpClient.java:299) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:792) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:744) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:669) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:913) at java.net.URLConnection.getContent(URLConnection.java:682) at java.net.URL.getContent(URL.java:1021) at Tp.main(Tp.java:20)