Solved

Web application with Windows (2000), Delphi 5/7 and Apache

Posted on 2006-10-26
3
322 Views
Last Modified: 2011-09-20
I wish to create a web application using Delphi 5 or Delphi 7
The application will need to :-
-  know which session it is talking to
-  be able to create a thread (within itself)
-  use components
-  send text/streams back to the client
-  be told to expire when the session has expired (to allow cleanup)

I only expect a total of < 20 instances (unique sessions) to be running at any 1 time.

Which type of web app should I create?
ISAPI/NSAPI, CGI stand-alone, Win-CGI, something else?
any suggestions welcome, and let me know if you need more info
0
Comment
Question by:TheRealLoki
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 500 total points
ID: 17817619
Not much experience with building Apache modules myself but here are my two cents...

About sessions, I think you might have to do session handling in your application itself. Often you get a session-ID from somewhere (Cookie, POST data or some URL parameter) and that will identify your session. If you have to create your own session ID's then use GUIDs, since they are very useful as unique identifiers...

Creating separate threads in a webserver is similar to creating threads in normal applications, although you have to be aware of the risk that your main thread might time-out before the other threads are finished. Creating child threads are therefor a bit risky since you might run out of resources. If you can avoid it, then don't use threads. The use of threads in web applications don't make much sense anyway since the webserver itself will run every request in it's own thread anyways.

For component use, use a WebModule or a data module. You won't be able to use visual components, though. Make sure that your components won't display some messageboxes or whatever since there will be no one available to click the [OK] button once it pops up. :-)

Sending data back to the client is not a real problem either. It's basic behaviour of the web module.

And about expiration... This too should be no problem since the module would just exist long enough to handle a single request before it is killed again. Keep in mind that webservers are stateless and thus every request you send to it will result in an action being started, it processes the incoming data, it generates the output and then the action is closed again! It won't continue to run until the next request...

It seems to me that you want some process to run in the background while a user is sending multiple requests to the server. To do this, you should actually split your project up in two parts. The first part is the web module which will be run from Apache. The second part should be a system service that will run in the background. Your webserver should talk to the system service, providing it the details about what it should do and the system service can run a thread for every session for the amount of time specified. The communication between system service and webserver can be done through named pipes, through TCP/IP and through many other inter-process communication tricks.

With a small amount of instances I would suggest that you start this project as a CGI application. It's easier to debug, although it might be slow if you have a huge amount of visitors. The advantage is that a CGI application is loaded every time a request is made and terminates when the request is done. An ISAPI DLL stays in memory after the first request and the only way to free it is by closing down the webserver. This means that every time you want to update the ISAPI DLL, you will have to stop the webserver, overwrite the DLL and then start the webserver...
Once your CGI application is working you can easily convert it to an ISAPI application if need be.
0
 
LVL 17

Author Comment

by:TheRealLoki
ID: 17839131
Thanks, I'll give that a go
It makes sense to use another background process, as long as I can pass it the "session id" or a guid each time, it should be fine. I can build in its'  own "lifetime"
0
 
LVL 17

Author Comment

by:TheRealLoki
ID: 17912301
I still haven't had a chance to fully implement it yet, but I've left you waiting long enough. Looks promiising so far, so here's your points
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

829 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