Thread View: borland.public.cppbuilder.internet.web
12 messages
12 total messages
Started by Ulli
Thu, 31 Mar 2005 13:17
AResponseInfo->Referer question
Author: Ulli
Date: Thu, 31 Mar 2005 13:17
Date: Thu, 31 Mar 2005 13:17
25 lines
1470 bytes
1470 bytes
I have a Indy WebSerber that I abuse to control some lights. Therefore I use the Document parameter of ARequestInfo like "DoSomething?Lihht_1_On" instead of requestion a htm page like "Whatever.htm". (A tip of Remy - thanks again). My Problem is now that the Browser expect a site back and the AResponseInfo->Referer gives me that just one time. On the first click in the browser Referer contains "Site_1.htm" and with ServeFile I can give the site back. On second click on the same link, Referer contains the string "DoSomething?Lihht_1_On". Any ideas thanks Ulli
Re: AResponseInfo->Referer question
Author: Remy Lebeau (TeamB)
Date: Thu, 31 Mar 2005 19:35
Date: Thu, 31 Mar 2005 19:35
17 lines
1465 bytes
1465 bytes
<Ulli> wrote in message news:opsoh67weogmwg2m@localhost... > My Problem is now that the Browser expect a site back > and the AResponseInfo->Referer gives me that just one time. > On the first click in the browser Referer contains "Site_1.htm" > and with ServeFile I can give the site back. On second click on > the same link, Referer contains the string "DoSomething?Lihht_1_On". As well it should be, since "DoSomething?Lihht_1_On" is the requesting page, from the browser's perspective. So what is the actual problem youare having? The browser is doing what it is supposed to be doing. Gambit
Re: AResponseInfo->Referer question
Author: Ulli
Date: Fri, 01 Apr 2005 09:54
Date: Fri, 01 Apr 2005 09:54
57 lines
2389 bytes
2389 bytes
The main problem is, that if I click on a link to switch the light, I don't want to change page in browser. Therefore I like give back the current page. But this works just one time, because as I already explained on click at the same link I get first the the current htm page in the "Referer" and on the second click "DoSomething..." and if I refere this the browser is showing an empty site (of course because "DoSome.." is not an existing htm page). So the problem is: switch light 1 -> Browser shows empty page use back button in browser to go to my link page again switch light 1 -> Browser shows empty page use back button in browser to go to my link page again ... and I would like to stay on the page. Thanks Ulli Am Thu, 31 Mar 2005 11:35:58 -0800 schrieb Remy Lebeau (TeamB) <no.spam@no.spam.com>: > > <Ulli> wrote in message news:opsoh67weogmwg2m@localhost... > >> My Problem is now that the Browser expect a site back >> and the AResponseInfo->Referer gives me that just one time. >> On the first click in the browser Referer contains "Site_1.htm" >> and with ServeFile I can give the site back. On second click on >> the same link, Referer contains the string "DoSomething?Lihht_1_On". > > As well it should be, since "DoSomething?Lihht_1_On" is the requesting > page, > from the browser's perspective. > > So what is the actual problem youare having? The browser is doing what > it > is supposed to be doing. > > > Gambit > >
Re: AResponseInfo->Referer question
Author: Hans Galema
Date: Fri, 01 Apr 2005 14:57
Date: Fri, 01 Apr 2005 14:57
29 lines
1742 bytes
1742 bytes
Ulli wrote: > switch light 1 -> Browser shows empty page Well if you do not want that then when not sending a page back with the same links ? > use back button in browser to go to my link page again > switch light 1 -> Browser shows empty page > use back button in browser to go to my link page again > ... > > and I would like to stay on the page. Why don't you just use key=value pairs ? In index.html <a href="Site_1.html">Lighswitching</a> In Site_1.html <a href="Site_1.html?Light_1=on">Light 1 on</a> <a href="Site_1.html?Light_1=off">Light 1 off</a> If there is not a key=value pair then just send Site_1.html. Otherwise do the same but first switch a light. Hans.
Re: AResponseInfo->Referer question
Author: Remy Lebeau (TeamB)
Date: Fri, 01 Apr 2005 18:13
Date: Fri, 01 Apr 2005 18:13
24 lines
1987 bytes
1987 bytes
<Ulli> wrote in message news:opsojsglxqgmwg2m@localhost... > The main problem is, that if I click on a link to switch > the light, I don't want to change page in browser. You have to. Every time you click on a link, it is a new page request, and a new download. Whether you send the same page data or not, that is up to you. But you do have to resend it each time the URL is re-requested. > Therefore I like give back the current page. But this works just one > time, because as I already explained on click at the same link I get > first the the current htm page in the "Referer" and on the second > click "DoSomething..." You are not supposed to be relying on the Referer like that to begin with. You are supposed to be looking at the actual requested URL instead. Whenever you send the page data, simply make sure that the link the user clicks on is the page you want. As I already explained earlier, the Referer is doing what it is supposed to be doing. The Referer is not the problem. Your reliance on it is. Gambit
Re: AResponseInfo->Referer question
Author: Ulli
Date: Mon, 04 Apr 2005 07:47
Date: Mon, 04 Apr 2005 07:47
47 lines
2093 bytes
2093 bytes
Hm, why not! First I wanted to have a Keywoard to know that the following is a control string, but I think this solution will be o.k. too - or better ;) Just one other question, ist there a more elegant way to split parameters at the "=" char than with .Pos amd .SubString Thanks Ulli Am Fri, 01 Apr 2005 16:57:57 +0200 schrieb Hans Galema <notused@notused.nl>: > Ulli wrote: > >> switch light 1 -> Browser shows empty page > > Well if you do not want that then when not sending a page > back with the same links ? > >> use back button in browser to go to my link page again >> switch light 1 -> Browser shows empty page >> use back button in browser to go to my link page again >> ... >> >> and I would like to stay on the page. > > Why don't you just use key=value pairs ? > > In index.html > > <a href="Site_1.html">Lighswitching</a> > > In Site_1.html > > <a href="Site_1.html?Light_1=on">Light 1 on</a> > <a href="Site_1.html?Light_1=off">Light 1 off</a> > > If there is not a key=value pair then just send Site_1.html. > Otherwise do the same but first switch a light. > > Hans.
Re: AResponseInfo->Referer question
Author: Hans Galema
Date: Mon, 04 Apr 2005 08:20
Date: Mon, 04 Apr 2005 08:20
29 lines
1896 bytes
1896 bytes
Ulli wrote:
> First I wanted to have a Keywoard to know that the following is a
> control string, but I think this solution will be o.k. too - or better ;)
<a href="Site_1.html?command=switch&Light_1=on">Light 1 on</a>
> Just one other question, ist there a more elegant way to split
> parameters at the "=" char than with .Pos amd .SubString
If there is only one key=value pair then that would be ok. You would
not even need to decode then as you could simply check:
if ( Pos ( URL, "Light_1=on" ) )
{
//switch light 1 on
}
if ( Pos ( URL, "Light_1=off" ) )
{
//switch light 1 off
}
You could even do that when you have more key=value pairs.
Otrherwise have a look at TStringList. CommaText and Names and Values
properties. Please read the help for that.
Hans.
Re: AResponseInfo->Referer question
Author: Ulli
Date: Mon, 04 Apr 2005 15:25
Date: Mon, 04 Apr 2005 15:25
46 lines
2093 bytes
2093 bytes
Ok thanks I thought there is some kind of parser in the Indie componant
for that anyway.
Ulli
Am Mon, 04 Apr 2005 10:20:34 +0200 schrieb Hans Galema
<notused@notused.nl>:
> Ulli wrote:
>
>> First I wanted to have a Keywoard to know that the following is a
>> control string, but I think this solution will be o.k. too - or better
>> ;)
>
> <a href="Site_1.html?command=switch&Light_1=on">Light 1 on</a>
>
>> Just one other question, ist there a more elegant way to split
>> parameters at the "=" char than with .Pos amd .SubString
>
> If there is only one key=value pair then that would be ok. You would
> not even need to decode then as you could simply check:
>
> if ( Pos ( URL, "Light_1=on" ) )
> {
> //switch light 1 on
> }
>
> if ( Pos ( URL, "Light_1=off" ) )
> {
> //switch light 1 off
> }
>
> You could even do that when you have more key=value pairs.
>
> Otrherwise have a look at TStringList. CommaText and Names and Values
> properties. Please read the help for that.
>
> Hans.
Re: AResponseInfo->Referer question
Author: Remy Lebeau (TeamB)
Date: Mon, 04 Apr 2005 17:40
Date: Mon, 04 Apr 2005 17:40
11 lines
1428 bytes
1428 bytes
<Ulli> wrote in message news:opsoprskcvgmwg2m@localhost... > Ok thanks I thought there is some kind of parser in > the Indie componant for that anyway. There is. The name=value pairs would be stored in the ARequestInfo.Params property, which is a TStrings descendant and thus has Name[] and Value[] subproperties to parse the data at the "=" character for you. Gambit
Re: AResponseInfo->Referer question
Author: Ulli
Date: Tue, 05 Apr 2005 13:50
Date: Tue, 05 Apr 2005 13:50
44 lines
2126 bytes
2126 bytes
Hi,
thanks. I knew there was some thing like that. But I couldn't remember.
Unfortunately the Values propertie is always empty the Names propertie is
ok.
The Tag is:
<a href="Site_1.htm?light_1=Off">Light Off</a>
for(int i = 0; i < ARequestInfo->Params->Count; i++)
{
as_Value = ARequestInfo->Params->Values[i];
as_Name = ARequestInfo->Params->Names[i];
// Rest of the code
}
Do I have a understanding problem how to use it?
Thanks
Ulli
Am Mon, 4 Apr 2005 10:40:37 -0700 schrieb Remy Lebeau (TeamB)
<no.spam@no.spam.com>:
>
> <Ulli> wrote in message news:opsoprskcvgmwg2m@localhost...
>> Ok thanks I thought there is some kind of parser in
>> the Indie componant for that anyway.
>
> There is. The name=value pairs would be stored in the
> ARequestInfo.Params
> property, which is a TStrings descendant and thus has Name[] and Value[]
> subproperties to parse the data at the "=" character for you.
>
>
> Gambit
>
>
Re: AResponseInfo->Referer question
Author: Remy Lebeau (TeamB)
Date: Tue, 05 Apr 2005 17:08
Date: Tue, 05 Apr 2005 17:08
67 lines
3098 bytes
3098 bytes
<Ulli> wrote in message news:opsorh16upgmwg2m@localhost...
> thanks. I knew there was some thing like that. But I couldn't
> remember. Unfortunately the Values propertie is always empty
> the Names propertie is ok.
You are not using it properly. The Values[] property expects a name as its
input parameter, not an index.
> The Tag is:
> <a href="Site_1.htm?light_1=Off">Light Off</a>
Use this instead:
AnsiString value = ARequestInfo->Params->Values["light_1"];
With that said, if the URL is only going to have a single light at a time, I
would suggest you change your URL to something more like the following
instead:
<a href="Site_1.htm?light=1&state=Off">Light Off</a>
Then you can do the following:
AnsiString asLight = ARequestInfo->Params->Values["light"];
AnsiString asState = ARequestInfo->Params->Values["state"];
if( (asLight != "") && (asState != "") )
// set the requested light to the specified state as needed...
else
// do something else...
If you don't do it this way, then you would have to loop through the Params
trying to parse them manually in order to find out which light is being
requested, ie:
AnsiString asName, asValue;
AnsiString asLight, asState;
int iPos;
for(int i = 0; i < ARequestInfo->Params->Count; ++i)
{
asName = ARequestInfo->Params->Strings[i];
iPos = asName.Pos("=");
if( iPos != 0 )
{
asValue = asName.SubString(iPos+1, MaxInt);
asName.SetLength(iPos-1);
}
else
asValue = "";
if( AnsiSameText(asName.SubString(1, 6), "light_") )
{
asLight = asName.SubString(7, MaxInt);
asState = asValue;
}
}
if( (asLight != "") && (asState != "") )
// set the requested light to the specified state as needed...
else
// do something else...
Gambit
Re: AResponseInfo->Referer question
Author: Ulli
Date: Wed, 06 Apr 2005 15:49
Date: Wed, 06 Apr 2005 15:49
2 lines
1104 bytes
1104 bytes
Many Thanks Ulli
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