I made a WBC class (below) that retrieve a web page.
The class constructer takes URL of desired page.
It worked well until I tried this page.
(http://www.wbc.com/wbc/member_list_company.asp?mode=show_new&letter=a)
The server gave me "request cannot be processed if object is closed..."
like that error, and I couldn't get whole HTML code of the page.
I guessed that Buffer was kinda small, so I tried 1MB as a
buffer(BufferedReader(...,1000000). BUT It Still doesn't work.
Anybody can help me out ?
Anyway, Please try my code and the URL.
import java.net.*;
import java.sql.*;
import sun.misc.*;
import java.io.*;
import java.util.*;
import java.text.*;
public class WBC{
String line = null;
String cat_name = null;
Connection con = null;
Statement stmt = null;
protected String host,file;
protected int port;
protected URL url;
protected Writer writer;
protected BufferedReader reader;
//public HashSet hashset;
String count_offers = null;
String next = null;
int count = 0;
public WBC(String url) throws MalformedURLException {
this.cat_name = cat_name;
this.url = new URL(url);
}
public void set_url(String url) throws
MalformedURLException {
this.url = new URL(url);
}
protected void get(){
String title="EMPTY";
try{
dissect();
connect();
fetch();
}catch(Exception e){
}
}
protected void dissect() throws MalformedURLException {
host = url.getHost();
port = url.getPort();
if(port == -1)
port = 80;
file = url.getFile();
}
protected void connect() throws IOException{
Socket socket = new Socket(host,port);
OutputStream out = socket.getOutputStream();
writer = new OutputStreamWriter(out,"latin1");
InputStream in = socket.getInputStream();
Reader reader = new InputStreamReader
(in,"latin1");
this.reader = new BufferedReader
(reader,1000000);
}
protected void fetch() throws IOException{
writer.write("GET " + file + " HTTP/1.0
\r\n\n");
writer.flush();
String input;
while( (input = reader.readLine() ) != null ){
System.out.println(input);
}
}
public static void main(String args[]) throws MalformedURLException, IOException{
WBC wbc = new WBC
("http://www.wbc.com/wbc/member_list_company.asp?mode=show_new&letter=a");
wbc.get();
}
}
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html