The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

POSTING data to CGI!!!!

Posted by Italo Gazzaneo on October 10, 2000 at 6:24 AM

Hi,
i have a big problem....and i hope you can help me!!!
I'm developing an AWT-Java Application that use Web-Sites to send SMS to mobile phones (in Italy)!!!
My problem is:
i have the URL indicating the cgi script that sends the message and analyzing the HTML code i have see the
name e the number of the parameters passed (with post method) from the form to the CGI.

I have to do the same thing....but the response from the Web-Sites is "Message is invalid".
I have used the same code found in the Thinking in Java but the answer is the same...
This is the code:

import java.util.*;
import java.net.*;
import java.io.*;

public class testHTTP
{
public static void main( String argv[] ) throws IOException
{
String cgiscript ="http://sms.jumpy.it/cgi-bin/sendsms.pl";
String query = null;
String line = "";
query = "messaggio=prova&prefisso=339&numero=6013911&num=120";

try
{
URL url = new URL(cgiscript);
URLConnection connection =
url.openConnection();
connection.setDoInput( true );
connection.setDoOutput( true );

DataOutputStream output = new DataOutputStream(
connection.getOutputStream() );
output.writeBytes( query );
output.close();

BufferedReader input = new BufferedReader(new
InputStreamReader(
connection.getInputStream()));

while ((line = input.readLine()) != null)
{
System.out.println(line);
}
input.close();
}
catch( Exception e ) {}
}
}

There is an error????
I took the cgi url from a program that makes the same things but written in VB5!

Hope you can help me....
Thankssssss & best regards!!!!




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us