Solved

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

Posted on 2006-10-26
3
319 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Print Graphic and Text to Epson TM-T88v 12 184
control image tags in a string ? 12 111
Convert MS Word document to a PDF file 9 64
PHP preg_replace code convert to Delphi 14 35
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

896 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now