Solved

A simple Delphi CGI application.

Posted on 2001-09-13
5
611 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 50 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

688 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