how to read content of a url that require login I want to use a java program to read content of a url,some codes are: URLConnection srcUrl = new URL(srcFile).openConnection();; DataInputStream datainput = new DataInputStream(srcUrl.getInputStream()); when read a common url,all is ok,but when read a page that require login,it show errors,for example,the error is : "<b>Fatal error</b>: Call to undefined function: () in <b>D:\web\epubcn\discuz\header.php</b> on line <b>224</b><br />" I think it relates to cookie problem,how can I solve this problem,thanks in advance.
Originally posted by li leon: how to read content of a url that require login.
When you make an HTTP connection to retrive some web page content , you use GET request metho of the HTTP protocol . So when it comes to some sort of authentication which requires a login interface , you would want to write to the URL first and then read the contents . So for writing to the URL you would have to change the request method from GET (default ) to POST by using the setRequestMethod("POST")the URLConnection class and would have use the outputstreams to write data that URl. Once you've finished writing ,start reding from it by using the input streams .Don't forget to close and flush the output streams . hope this helps. [ October 20, 2002: Message edited by: raghav mathur ]