Hello Friends
I have written a piece of
java code that simulates a POST method. the code works well in my friend's computer and gives me the expected HTML page output. But when I run at my comp at work place (a different network from the one my friend is connected to)....I get a connection time out error.
so I guess there is no problem with my code..I would be grateful if any of you guys out there..could help me solve the problem.Should I change some settings in my computer...or is there a way to tweak my code and get it running correctly. I even tried using the URL mentioned in the code accesing the HTML page thru browser..It works!!!...but when I simulate the POST Method in my code and try to make it run..(without using the browser) I get "java.net.ConnectException: Connection timed out: connect". Please help me...in finding the solution.
I have pasted my code below....
Thanks!
Srihari
/*******************************************
package Pratt;
import java.io.*;
import java.net.*;
import java.util.*;
public class Pratt {
URL url;
URLConnection urlConn;
DataOutputStream dout;
public Pratt() throws Exception {
url = new URL ("http://www2.ebi.ac.uk/cgi-
bin/prattparser.pl");
urlConn = url.openConnection();
urlConn.setDoInput (true);
urlConn.setDoOutput (true);
urlConn.setUseCaches (false);
urlConn.setRequestProperty("Content-
type", "application/x-www-form-urlencoded");
dout = new DataOutputStream
(urlConn.getOutputStream ());
String content =
"sequence=" + URLEncoder.encode ("aksjkljdklajdlk") +
"&USEDATA=" + URLEncoder.encode ("RUN PRATT") +
"&C%=" + URLEncoder.encode ("100.0")+
"&PP=" + URLEncoder.encode ("off")+
"&PL=" + URLEncoder.encode ("50")+
"&PN=" + URLEncoder.encode ("50") +
"&PX=" + URLEncoder.encode ("5")+
"&FN=" + URLEncoder.encode ("2")+
"&FL=" + URLEncoder.encode ("2")+
"&FP=" + URLEncoder.encode ("10")+
"&BI=" + URLEncoder.encode ("off")+
"&BN=" + URLEncoder.encode ("20")+
"&S=" + URLEncoder.encode ("info")+
"&G=" + URLEncoder.encode ("seq")+
"&E=" + URLEncoder.encode ("3")+
"&R=" + URLEncoder.encode ("on")+
"&RG=" + URLEncoder.encode ("off")+
"&OP=" + URLEncoder.encode ("on")+
"&ON=" + URLEncoder.encode ("50")+
"&OA=" + URLEncoder.encode ("50")+
"&M=" + URLEncoder.encode ("on")+
"&MR=" + URLEncoder.encode ("10")+
"&MV=" + URLEncoder.encode ("off");
dout.writeBytes (content);
dout.flush ();
dout.close ();
BufferedReader din = new BufferedReader(new
InputStreamReader(urlConn.getInputStream ()));
(urlConn.getInputStream ());
String str;
while (null != ((str = (din.readLine()))))
System.out.println (str);
din.close ();
}
public static void main(String[] args) {
try {
new Pratt();
}catch (Exception e) {
e.printStackTrace();
}
}
}
[ July 18, 2002: Message edited by: Srihari Venkatesan ]
[ July 19, 2002: Message edited by: Srihari Venkatesan ]