Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

the CGI for IIS (PWS) servers

Posted on 2000-03-14
14
Medium Priority
?
202 Views
Last Modified: 2013-11-18
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.
0
Comment
Question by:sviksna
  • 5
  • 3
  • 3
  • +2
14 Comments
 
LVL 3

Expert Comment

by:ckaneta
ID: 2617111
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
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2617193
0
 

Expert Comment

by:mike_tipping
ID: 2619034
remember to enable CGI on the website in IIS (well it caught me out for a while)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:sviksna
ID: 2620007
ckaneta,
it would be nice. thank you.

Sandis.
0
 
LVL 3

Expert Comment

by:ckaneta
ID: 2620244
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

0
 
LVL 1

Author Comment

by:sviksna
ID: 2620600

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?
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2621321
The second writeln is not right. Change or remove it and try again.
0
 
LVL 17

Expert Comment

by:geobul
ID: 2622801
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
0
 
LVL 1

Author Comment

by:sviksna
ID: 2623698
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.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2624828
Use cookies. This is how asp sessions work...
0
 
LVL 17

Accepted Solution

by:
geobul earned 150 total points
ID: 2626952
Hi,

Setting cookies :

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  slCookies : TStringList;
  login, passw : string;
begin
  slCookies := TStringList.Create;
  ...
  { reading values from somewhere - from Request here }
  login:=Request.ContentFields.Values['login'];
  passw:=Request.ContentFields.Values['passw'];
  .....
  { adding cookies to string list }
  slCookies.Add('login='+login);
  slCookies.Add('passw='+passw);
  { set cookies in Response }
  Response.SetCookieField(slCookies,'','',Request.Date-1,False);
  .......
  slCookies.Free;
end;


Reading cookies:

procedure TWebModule1.WebModule1WebActionItem2Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  login, passw : String;
begin
  ...
  login := Request.CookieFields.Values['login'];
  passw := Request.CookieFields.Values['passw'];
  ...
end;

Regards, Geo
0
 
LVL 1

Author Comment

by:sviksna
ID: 2627585
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?
0
 
LVL 17

Expert Comment

by:geobul
ID: 2628554
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
0
 
LVL 1

Author Comment

by:sviksna
ID: 2636966
This was one of moust useable anwers.
Thank You.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question