?
Solved

A simple Delphi CGI application.

Posted on 2001-09-13
5
Medium Priority
?
672 Views
Last Modified: 2013-11-18
Could someone do me a walk-through description of creating a Delphi CGI application that simply accepts a variable (person's name) and creates a HTML page that says hello to that person?

My server-side scripting is okay, and I get how it works, but don't know how to create it in Delphi.  (Just got some web space on an NT server.)

Thanks,

John.
0
Comment
Question by:Jaymol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6478826
Hello

I prefer to use ISAPI, it's better than CGI and have more benefits more than the CGI

here's a good site for ISAPI Tutorials, it fully made by delphi

http://www.matlus.com/scripts/website.dll

and here's some link for CGI

delphi and CGI
http://www.drbob42.com/books/cgi.htm
http://www.drbob42.com/books/cgi-data.htm


Writing a fancy CGI hit counter in Delphi 5
http://homepages.borland.com/aohlsson/Articles/CounterCGI.html

Web Programming in Delphi
http://www.209software.com/books/wpid/ 

Best regards
Mohammed Nasman
0
 
LVL 17

Accepted Solution

by:
geobul earned 200 total points
ID: 6479465
Hi John,

1.From File-New select 'Web server app'.
2.From the next menu select 'CGI standalone exe'.
3.You will see a tree WebModule1-Actions. Select 'Actions', right-click on it and select 'Add Item' from the popup menu. WebActionItem1 appears.
4.Select that item and change its 'Default' property to True - this means that that item will be executed on every request.
5.Create an OnAction event handler for that item like the following:

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  UserName : string;
begin
  UserName := Request.QueryFields.Values['name'];
  Response.Content := '<HTML><BODY>Hello ' + UserName + '</BODY></HTML>';
  Response.SendResponse;
  Handled := True;
end;

6.Build the CGI app as 'MyCGI.exe' for example and place it on the server.

7. Calling your app from a html page:
Your html link to call that CGI should look like:

<A HREF="www.hostname.com/path/MyCGI.exe?name=John">Click me</A>

Here 'name' is a query field and 'John' is its value, which value will be passed to your app.

Another way:
If you want to use a html form for calling your app, then 1.Change the WebActionItem1 'MethodType' property from mtAny to mtPost. (optional)
2.In the code above use 'ContentFields' instead of 'QueryFields'.
3.Call the app from a html page like:

<HTML>
<HEAD><TITLE><Test Hello CGI></TITLE></HEAD>
<BODY>
<FORM METHOD=POST ACTION="www.hostname.com/path/MyCGI.exe">
<INPUT TYPE=text NAME="name"  VALUE="">
<INPUT TYPE=submit VALUE="Submit">
</FORM>
</BODY>
</HTML>

Regards, Geo
0
 
LVL 6

Author Comment

by:Jaymol
ID: 6486930
Thanks for your help.

John.
0
 
LVL 17

Expert Comment

by:geobul
ID: 6487069
You are welcome.

Regards, Geo
0
 
LVL 6

Author Comment

by:Jaymol
ID: 6487100
Geo, could you look at the other question I have open?

John.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

770 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