Link to home
Start Free TrialLog in
Avatar of sviksna
sviksna

asked on

the CGI for IIS (PWS) servers

Hello, Experts.
I have problems with making CGI. So, I have D4 with internet components. So, I am loking for information about building CGI applications. All kind.. from counters till shoping things.

Thank you for your help.
Sandis Viksna.
Avatar of ckaneta
ckaneta

create a Delphi console application, replace the typical source code with something like this:

program cgi;
{$apptype console}

uses Sysutils;

begin
 writeln('HTTP/1.0 200 OK');
 writeln('CONTENT-TYPE: TEXT/HTML');
 writeln('<html><head>');
 writeln('<title>blah blah</title>');
 writeln('</head><body>');
 writeln('</body></html>');
end.
basically from Cantu's book.
I can try to dig up a sample and send it if you like
remember to enable CGI on the website in IIS (well it caught me out for a while)
Avatar of sviksna

ASKER

ckaneta,
it would be nice. thank you.

Sandis.
okay, either write to me at ckan1010@aol.com and I'll send it in a reply or get it from here

members.xoom.com/kaneta/dwnld/cgistuff.zip

~ or ~

members.xoom.com/kaneta
and go to the 'stuff' page

Avatar of sviksna

ASKER


the code
program response;
{$apptype console}

uses Sysutils;

begin
 writeln('HTTP/1.0 200 OK');
 writeln('CONTENT-TYPE: TEXT/HTML');
 writeln('<html><head>');
 writeln('<title>blah blah</title>');
 writeln('</head><body> here it is dude');
 writeln('</body></html>');
end.

----------------------
the result
-----------------------
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:


HTTP/1.0 200 OK
CONTENT-TYPE: TEXT/HTML


here it is dude
-------------------------

can u help me?
The second writeln is not right. Change or remove it and try again.
Hi,

Select 'File-New-Web Server Application' from Delphi main menu and then 'CGI Stand-alone Executable'. This way you have created new CGI project with WebModule. In WebModule you can add Action Items for different HTTP methods like GET and POST and for different 'commands' after the name of your CGI script, defined in the calling HTML page like
....
<FORM METHOD=POST ACTION="/scripts/MyScript.exe/login">
.....
where 'MyScript.exe' is the name of the script and '/login' is the 'command', corresponding with Action Item with PathInfo property = /login.
  There are Request object containing all information about the client's browser request and Response object which Content property your program has to fill with HTML page and send back using SendResponse method.

  You have to build the exe and copy to the scripts directory of the Web server.

It's not so hard stuff as it sounds.

Regards, Geo
Avatar of sviksna

ASKER

The advice one step up is ok. But how to do with thing like session() in ASP. How i can pass the data in novisual mode, i meant with this, that data isn't visible into the location bar, like
some.exe?name=john&regnum=32434234

couse, these params are constants for current user in all pages, but i don't wana write them in the HTML code as Hiden object (<input type="hiden"..) security for...

so, is there any solution for this?

Sandis.
Use cookies. This is how asp sessions work...
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sviksna

ASKER

hi, geo, again

{ reading values from somewhere - from Request here }
  login:=Request.ContentFields.Values['login'];
  passw:=Request.ContentFields.Values['passw'];


is that like value
cgi-bin/myapp.exe/login=loginame&passw=somepass


am i right?
Hi,

  I'm using POST method in my example and login and pass values are in the content property of the request (INPUT text/password html tags and a button).
  You are using GET method in your example and the info is in the query property of the request. So the code will be:

login:=Request.QueryFields.Values['login'];
  passw:=Request.QueryFields.Values['passw'];

Regards, Geo
Avatar of sviksna

ASKER

This was one of moust useable anwers.
Thank You.