Hi,
I have the following problem,
I have connected to a web server using the HTTPCLient library provided by Innovation.ch and have posted some data to a web server (using the code that I have added at the bottom of this post).. and want to be able to view the data that has been returned from the server.. however, the data is stored in another page - for which I have a hyperlink.
I was hoping that somebody could tell me how i can access the data stored in the hyperlink (such as and then return this data to my System console.
Any Help with this would be much appreciated.
Thanks again
The code I have used to connect to the web server is as follows:
public class Promoter {
private String sequence;
private String enterSequence;
private String str;
private String resultURL;
public Promoter(String seq) {
sequence = seq;
try{
URI doc_url = new URI (" URI form_url = new URI (doc_url,"/cgi-bin/nph-webface"
HTTPConnection con = new HTTPConnection(form_url);
NVPair[] form_data = new NVPair[] { new NVPair("configfile", "/usr/opt/ new NVPair("SEQPASTE", sequence),
new NVPair("full", "full",
new NVPair"submit", "Submit",
};
con.setDefaultHeaders (new NVPair[]{ new NVPair("User-Agent", "Mozilla/4.5"});
HTTPResponse resp = con.Post(form_url.getPathAndQuery(), form_data);
String Output = "";
if(resp.getStatusCode () >=300){ System.err.println("Received Error:"+ resp.getReasonLine());
//System.err.println(resp.getText());
}
else {
DataInputStream input = new DataInputStream(resp.getInputStream());
resultURL = "";
while(null != ((str = input.readLine()))){ System.out.println(str);
Output += str;
} // Regular expression to retreive Pattern p = Pattern.compile("\\w.*\\.\\w.*\\(\"(\\w{4}:.*\\wait)"
Matcher m = p.matcher(Output);
String foo = "";
if(m.find()){
foo = m.group(1);
resultURL = foo;
PromoterResults pr = new PromoterResults(resultURL);
System.out.println("this is the link that I have captured - " + foo);
}
else if(!m.find()){
System.out.println("the URL has not been captured"
} input.close();
} }catch(IOException ioe){ System.err.println(ioe.toString());
}catch (ParseException pe) { System.err.println("Error parsing Content-Type: " + pe.toString());
} catch (ModuleException me) { System.err.println("Error handling request: " + me.getMessage());
}
}
}
I have the following problem,
I have connected to a web server using the HTTPCLient library provided by Innovation.ch and have posted some data to a web server (using the code that I have added at the bottom of this post).. and want to be able to view the data that has been returned from the server.. however, the data is stored in another page - for which I have a hyperlink.
I was hoping that somebody could tell me how i can access the data stored in the hyperlink (such as and then return this data to my System console.
Any Help with this would be much appreciated.
Thanks again
The code I have used to connect to the web server is as follows:
public class Promoter {
private String sequence;
private String enterSequence;
private String str;
private String resultURL;
public Promoter(String seq) {
sequence = seq;
try{
URI doc_url = new URI (" URI form_url = new URI (doc_url,"/cgi-bin/nph-webface"
HTTPConnection con = new HTTPConnection(form_url);
NVPair[] form_data = new NVPair[] { new NVPair("configfile", "/usr/opt/ new NVPair("SEQPASTE", sequence),
new NVPair("full", "full",
new NVPair"submit", "Submit",
};
con.setDefaultHeaders (new NVPair[]{ new NVPair("User-Agent", "Mozilla/4.5"});
HTTPResponse resp = con.Post(form_url.getPathAndQuery(), form_data);
String Output = "";
if(resp.getStatusCode () >=300){ System.err.println("Received Error:"+ resp.getReasonLine());
//System.err.println(resp.getText());
}
else {
DataInputStream input = new DataInputStream(resp.getInputStream());
resultURL = "";
while(null != ((str = input.readLine()))){ System.out.println(str);
Output += str;
} // Regular expression to retreive Pattern p = Pattern.compile("\\w.*\\.\\w.*\\(\"(\\w{4}:.*\\wait)"
Matcher m = p.matcher(Output);
String foo = "";
if(m.find()){
foo = m.group(1);
resultURL = foo;
PromoterResults pr = new PromoterResults(resultURL);
System.out.println("this is the link that I have captured - " + foo);
}
else if(!m.find()){
System.out.println("the URL has not been captured"
} input.close();
} }catch(IOException ioe){ System.err.println(ioe.toString());
}catch (ParseException pe) { System.err.println("Error parsing Content-Type: " + pe.toString());
} catch (ModuleException me) { System.err.println("Error handling request: " + me.getMessage());
}
}
}