dcsimg
Reading in a URL/cgi output to a servlet
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Syed_Abbas
Posted On:   Thursday, June 14, 2001 03:12 PM

I am trying to read in the contents of a url http://213.107.33.171/scripts/mqinterconnect.exe?link=map&city=london&country=uk And failing! The code is :- String hostname = "213.107.33.171"; int port = 80 ; String filename = "/scripts/mqinterconnect.exe?link=map&city=london&country=uk "; String record = null; Socket s = new Socket(hostname, port); int recCount = 0; try { InputStream sin = s.getInputStream(); BufferedReader fromServer = new BufferedReader(new InputStreamReader(sin)); OutputStream sout = s.getOutputStream(); PrintWriter toServer = new PrintWriter(new Outp   More>>

I am trying to read in the contents of a url

http://213.107.33.171/scripts/mqinterconnect.exe?link=map&city=london&country=uk

And failing!
The code is :-


			

String hostname = "213.107.33.171";
int port = 80 ;
String filename = "/scripts/mqinterconnect.exe?link=map&city=london&country=uk
";
String record = null;
Socket s = new Socket(hostname, port);
int recCount = 0;

try {
InputStream sin = s.getInputStream();
BufferedReader fromServer = new BufferedReader(new InputStreamReader(sin));
OutputStream sout = s.getOutputStream();
PrintWriter toServer = new PrintWriter(new OutputStreamWriter(sout));

out.print("Get" + filename + "http:///
");
toServer.println("Get " + filename + " http:///
");

record = new String();

while ((record = fromServer.readLine()) != null) {
recCount++;
out.println(recCount);

} toServer.close();
fromServer.close();
s.close();



Please help!    <<Less

Re: Reading in a URL/cgi output to a servlet

Posted By:   Tim_Rohaly  
Posted On:   Thursday, June 14, 2001 04:23 PM

If you're going to talk HTTP over a socket, I would
suggest you read the HTTP specification at
http://www.w3.org/Protocols/.
You are not following the protocol. Also, you should
read the Networking FAQs and Forums - this is discussed.
About | Sitemap | Contact