🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
10 messages
10 total messages Started by dave Tue, 22 Aug 2006 17:07
how to send a string to a url
#672
Author: dave
Date: Tue, 22 Aug 2006 17:07
8 lines
816 bytes
Hello,

Could someone show me some code on how to send a string of data to a url?

Thanks,

---Dave
Re: how to send a string to a url
#673
Author: Remy Lebeau (TeamB)
Date: Tue, 22 Aug 2006 17:30
12 lines
1273 bytes
"dave" <dave@nowhere.com> wrote in message
news:44eb39e3$2@newsgroups.borland.com...

> Could someone show me some code on how to send a string of data to a url?

That depends on what kind of URL it is, how the server expects the string to
arrive and how it should be formatted  Please provide more details about
what EXACTLY you want to accomplish.


Gambit
Re: how to send a string to a url
#674
Author: dave
Date: Tue, 22 Aug 2006 18:30
38 lines
1950 bytes
Well the URL I an sending the string info to is Tomcat (similar to a appache).


Here is some java code which I am trying to do with Builder.


try{
   java.net.URL url = new java.net.URL("http://localhost:8084/SiteTracking/SiteTrackerVersionUpdater");
   java.net.URLConnection connection = url.openConnection();
   connection.setDoOutput(true);			
   connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 
			
   java.io.OutputStream out = connection.getOutputStream();
			//connection.connect();

	
//HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!		
   out.write(new String("CREATE TABLE test (`Key_ID` INT(11) NOT NULL)\r\n").getBytes());
//END HERE !!!!!!!!		

	
   out.flush();
   java.io.BufferedReader in = new java.io.BufferedReader(
			  new java.io.InputStreamReader(
			  connection.getInputStream()));   
 
   in.close();  			
   out.close();
   }catch(Exception ex)
   {
      System.out.println(e.toString());
   }




Obviously I will be sending this to a different IP addresss than my local machine when I get it to work.
Re: how to send a string to a url
#675
Author: Remy Lebeau (TeamB)
Date: Tue, 22 Aug 2006 22:21
14 lines
1462 bytes
"dave" <dave@here.com> wrote in message
news:44eb4d5d$1@newsgroups.borland.com...

> Here is some java code which I am trying to do with Builder.

Such code would send a GET request to the server.  It is unusual to send
body content in a GET request.  Are you sure that the server does not expect
a POST request instead?  Does the code you have shown actually work as you
have shown it?  What data do you see if you use a packet sniffer, such as
Ethereal (http://www.ethereal.com)?


Gambit
Re: how to send a string to a url
#676
Author: Dave
Date: Wed, 23 Aug 2006 13:42
27 lines
1879 bytes
Hello again,

I talked to the developer who wrote that java code...it appears to be a Get request but it is really a Post request.

The code does work because there is servlet behind Tomcat that will take these strings and do what it needs to do with them.
The SQL string that is passed to that servlet does actually issue that command the the MySQL server on that server.



"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>"dave" <dave@here.com> wrote in message
>news:44eb4d5d$1@newsgroups.borland.com...
>
>> Here is some java code which I am trying to do with Builder.
>
>Such code would send a GET request to the server.  It is unusual to send
>body content in a GET request.  Are you sure that the server does not expect
>a POST request instead?  Does the code you have shown actually work as you
>have shown it?  What data do you see if you use a packet sniffer, such as
>Ethereal (http://www.ethereal.com)?
>
>
>Gambit
>
>
Re: how to send a string to a url
#677
Author: Remy Lebeau (TeamB)
Date: Wed, 23 Aug 2006 16:58
63 lines
2532 bytes
"Dave" <dave@here.com> wrote in message
news:44ec5b63$1@newsgroups.borland.com...

> I talked to the developer who wrote that java code...it appears
> to be a Get request

According to the Java documentation, the code you showed would send a GET
request.  That is why I asked.

> but it is really a Post request.

I thought as much.  In that case, if you were to use Indy
(http://www.indyproject.org), then the Java code you showed earlier would
translate as the following:

    try
    {
        TStringList *content = new TStringList;
        try
        {
            content->Text = "CREATE TABLE test (`Key_ID` INT(11) NOT NULL)";

            IdHTTP1->Request->ContentType =
"application/x-www-form-urlencoded";

IdHTTP1->Post("http://localhost:8084/SiteTracking/SiteTrackerVersionUpdater"
, content);
        }
        __finally {
            delete content;
        }
    }
    catch(const Exception &e)
    {
        ShowMessage(e.Message);
    }

Alternatively:

    try
    {
        TStringStream *content = new TStringStream("CREATE TABLE test
(`Key_ID` INT(11) NOT NULL)\r\n");
        try
        {
            IdHTTP1->Request->ContentType =
"application/x-www-form-urlencoded";

IdHTTP1->Post("http://localhost:8084/SiteTracking/SiteTrackerVersionUpdater"
, content);
        }
        __finally {
            delete content;
        }
    }
    catch(const Exception &e)
    {
        ShowMessage(e.Message);
    }


Gambit
Re: how to send a string to a url
#678
Author: Dave
Date: Thu, 24 Aug 2006 15:05
4 lines
1171 bytes
You are a amazing wealth of info Gambit!  That code works great!  Thanks again Gambit!

Just curious do you work for Borland?
Re: how to send a string to a url
#679
Author: Remy Lebeau (TeamB)
Date: Thu, 24 Aug 2006 16:52
11 lines
1357 bytes
"Dave" <blah@blah.com> wrote in message
news:44edc045$1@newsgroups.borland.com...

> Just curious do you work for Borland?

No, I do not, but TeamB is strongly affiliated with Borland.  We work
hand-in-hand together, so to speak.


Gambit
Re: how to send a string to a url
#693
Author: Richard
Date: Mon, 04 Sep 2006 05:17
10 lines
1319 bytes
On Thu, 24 Aug 2006 09:52:26 -0700, "Remy Lebeau \(TeamB\)"
<no.spam@no.spam.com> wrote:

>
>"Dave" <blah@blah.com> wrote in message
>news:44edc045$1@newsgroups.borland.com...
>
>> Just curious do you work for Borland?

Are you one person?
Re: how to send a string to a url
#696
Author: Remy Lebeau (TeamB)
Date: Mon, 04 Sep 2006 19:16
16 lines
1815 bytes
"Richard" <nospam@nospam.net> wrote in message 
news:hldnf2h6g4c2uk85tcce91t4s878s021nh@4ax.com...

> Are you one person?

We are all individuals.  In that regard, yes I am one person ;-)

If you are asking if I work alone, then yes and no.  Yes, in that I run my 
own software company (http://www.lebeausoftware.org) by myself.  No, in that 
I do have a day job where I work in a group of programmers, and also TeamB 
(http://www.teamb.com) and Indy (http://www.indyproject.org) are groups as 
well.


Gambit 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads