🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #1333

Re: CGI Web server Application

#1333
From: Butch McLeod
Date: Sun, 27 Mar 2005 16:30
85 lines
4732 bytes
I am using C++ Builder version 5 on a computer running Windows XP Pro with 
SP2 installed.
I click on file | new | Web Server Application and then choose "CGI Stand 
Alone Executable".This creates a TWebModule that I renamed "Main".
I then add a web action Item called WebActionItem1 and change the path info 
property to "/home".
For the OnAction event for WebActionItem1 I add this code: Response->Content 
= "<p>Hello</p>";
I build the app (named MyWebApp) directing the final output to the default 
web site defined in the Internet Information Service snap in.Permissions are 
set to scripts and executables.
I open internet explorer version 6.0.2900.2180.xpsp_sp2_rtm.040803-2158 and 
in the address bar I enter "http://HAL/MyWebApp.exe/home." Internet Explorer 
displays a page with Hello on it.

//---------------------------------------------------------------------------
#include "Main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TWebModule1 *WebModule1;
//---------------------------------------------------------------------------
__fastcall TWebModule1::TWebModule1(TComponent* Owner): TWebModule(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TWebModule1::WebModule1WebActionItem1Action(
      TObject *Sender, TWebRequest *Request, TWebResponse *Response,
      bool &Handled)
{
   Response->Content = "<p>Hello</p>";
}
//---------------------------------------------------------------------------

Then I add a TDatabase component (named Database1) to the TWebModule and set 
the Database AliasName property and the DatabaseName propertyto BCDEMOS and 
the connect property to true.
I build the app again.
I open Internet Explorer and in the address bar I enter 
http://HAL/MyWebApp.exe/home.
The result is: The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be 
displayed.
HTTP 500 - Internal server error
Internet Explorer

If I set the connected property for the database to false and build the app 
again it works

If I use code to connect the database it doesn't work.
//---------------------------------------------------------------------------
#include "Main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TWebModule1 *WebModule1;
//---------------------------------------------------------------------------
__fastcall TWebModule1::TWebModule1(TComponent* Owner): TWebModule(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TWebModule1::WebModule1WebActionItem1Action(
      TObject *Sender, TWebRequest *Request, TWebResponse *Response,
      bool &Handled)
{
   Database1->Connected = true;
   Database1->Connected = false;
   Response->Content = "<p>Hello</p>";
}
//---------------------------------------------------------------------------

I worked my way down to this example. First I tried to use a datamodule from 
an application I developed using Interbase and C++ Builder about 4 years 
ago. The client would like to have remote access to his data.
When I couldn't get a table to display using the TDataSetTableProducer 
component, I started simplifying things to try to discover the cause. Thats 
how I found that just connecting to a database causes it to fail.

I have tried some examples I found on the internet but I have not been able 
to get them to work either.
Any help is appreciated.

ThanksButch
Technical Details
Message-ID: <4246dfeb$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!news2.euro.net!newsfeed.freenet.de!80.239.136.22.MISMATCH!tsicnews.teliasonera.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <424613ab@newsgroups.borland.com> <42469f0f$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,af8465d282730681
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Butch McLeod" <leverenemcleod@eastlink.ca>
Newsgroups: borland.public.cppbuilder.internet.web
References: <424613ab@newsgroups.borland.com> <42469f0f$1@newsgroups.borland.com>
Subject: Re: CGI Web server Application
Date: Sun, 27 Mar 2005 12:30:19 -0400
Lines: 87
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 156.34.81.136
Message-ID: <4246dfeb$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1111941099 156.34.81.136 (27 Mar 2005 08:31:39 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!news2.euro.net!newsfeed.freenet.de!80.239.136.22.MISMATCH!tsicnews.teliasonera.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail