Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-10-26
3
Medium Priority
?
331 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
[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
3 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

705 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