Thread View: borland.public.cppbuilder.internet.web
6 messages
6 total messages
Started by Butch McLeod
Sun, 27 Mar 2005 01:58
CGI Web server Application
Author: Butch McLeod
Date: Sun, 27 Mar 2005 01:58
Date: Sun, 27 Mar 2005 01:58
13 lines
1447 bytes
1447 bytes
I created a CGI web server app using C++ Builder 5 Pro with 1 web action item: Response->Content = "<p>HELLO</p>"; Built the project and opened it with IE 6 and was rewarded with a page that has "HELLO" on it. I'm using the Internet Information Server that comes with XP Pro If I add a database component to the webmodule and connect to a database, I'm rewarded with page cannot be displayed . If I connect to a database and then disconnect right away. Page cannot be displayed If I don't connect to a database it works. Any ideas as to why I can't create a web server app that uses a database? Thanks
Re: CGI Web server Application
Author: Hans Galema
Date: Sun, 27 Mar 2005 11:52
Date: Sun, 27 Mar 2005 11:52
26 lines
2023 bytes
2023 bytes
Butch McLeod wrote: > I created a CGI web server app using C++ Builder 5 Pro with 1 web action > item: Response->Content = "<p>HELLO</p>"; > Built the project and opened it with IE 6 and was rewarded with a page that > has "HELLO" on it. I'm using the Internet Information Server that comes with > XP Pro > If I add a database component to the webmodule and connect to a database, > I'm rewarded with page cannot be displayed . What is further in that page ? Is the connection successfule ? What do you do after a succesfull connection ? What do you do after an unsuccesfulle connection ? > If I connect to a database and then disconnect right away. Page cannot be > displayed But what kind of responce content are you filling in then ? > If I don't connect to a database it works. Any ideas as to why I can't > create a web server app that uses a database? Please be more specific about what and how you are doing ? A cgi app can do all kinds of things. But you have to care for it that it does not AV. And catch exceptions. Hans.
Re: CGI Web server Application
Author: Butch McLeod
Date: Sun, 27 Mar 2005 16:30
Date: Sun, 27 Mar 2005 16:30
85 lines
4732 bytes
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
Re: CGI Web server Application
Author: Hans Galema
Date: Sun, 27 Mar 2005 16:57
Date: Sun, 27 Mar 2005 16:57
39 lines
2151 bytes
2151 bytes
Butch McLeod wrote:
> 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.
Is that webserver running on the same computer as IE and bcb >
> 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
And did you look in the error.log file of the webserver ?
> 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.
Are you sure that the alias for a your database is valid for the
cgi-exe ?
> Database1->Connected = true;
> Database1->Connected = false;
> Response->Content = "<p>Hello</p>";
You did not add a try-catch block around the statement that
causes troubles.
try
{
Database1->Connected = true;
}
catch ( &Exception &exception )
{
//error
}
Hans.
Re: CGI Web server Application
Author: Butch McLeod
Date: Sun, 27 Mar 2005 18:29
Date: Sun, 27 Mar 2005 18:29
49 lines
2823 bytes
2823 bytes
The BCDEMOS alias is installed during the installation of C++ Builder 5 pro
and is used by some of the example apps and it works on my computer.
I have also tried connections to other databases I've created using paradox
and Interbase. The only place they don't work is in a cgi web server app.
If I add a TTable component, set to active in the designer, add the
TDataSetTableProducer component set and set up the columns, data displays in
the TDataSetTableProducer component while in the designer.
The following code returns:
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
#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)
{
try
{
Database1->Connected = true;
}
catch(EDatabaseError &E)
{
Response->Content = "<p>Database Error</p>";
}
catch(...)
{
Response->Content = "<p>Other Error</p>";
}
Response->Content = "<p>Hello</p>";
}
//---------------------------------------------------------------------------
Butch.
Re: CGI Web server Application
Author: Hans Galema
Date: Sun, 27 Mar 2005 18:58
Date: Sun, 27 Mar 2005 18:58
20 lines
1673 bytes
1673 bytes
Butch McLeod wrote: > 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 This is a strange error message. Why does IE complain that it cannot display a pag e? Otherwise IE displays just any page, well formatted or not. And now it would complain ? One would expect an error like "I cannot produce the page" and then not from IE of course. Take a HTTP component and see what it gets using your url. What does happen if you run your cgi.exe from the command prompt? Try using a different webserver. Hans.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads