How do I parse ASP code to HTML?

I have looked all over but cannot find a way to do this, IIS does it, Apache does it with Chillisoft ASP but I have my own web server in delphi (based on Indy 9 demo using IdHTTPServer) which works great but cannot handle ASP pages.  In theory this should not be that difficult, I just need to parse the ASP file through an engine of some sort so it is pure html ready to pass back to the client as IIS and Chillisoft does.

Anyone know how I can achieve this? I am using the following ASP code to test, the browser shows "testing..." and nothing else...

<title> My First ASP Page </title>
' Comment - The asp code which is ignored by IdHTTPServer component and the browser..
Response.Write "<p>This is a test of ASP.</p>"

Any help with this would be much appreciated, I was expecting to find a dll out there which you could pass ASP code through and have the HTML code returned that the client browser would use instead but no such luck! am I the first person to try to do this? am I going about this the wrong way??

If you need further explanation please do ask.  Not sure whether this is a difficult one or not, will increase points if it proves to be.

This question in a nutshell is "How do I process ASP code using Delphi so that I just end up with the final html file that can be loaded into a browser?"

Thanks in advance,
Justin Willis
Who is Participating?
VoodoomanConnect With a Mentor Commented:

The architecture of IIS depends on two engines (as I understand it) a normal Webserver and an ASP Server.

Pages marked as .ASP are sent to the ASP Server Engine and delivered as HTML.

If you could bother to write your own .ASP Engine (which basically generates HTML dynamically) you could then send your HTML to your Webserver.

Your ASP Server would be a script engine (there are VB script  and Oascal Engines available for Delphi - see ) that you could use to create your own Script Engine.

Just loop thru the characters in the html until you get to the <% then grab the script between the tags and process it with you engine.

Add the resultant code to the original HTML and add the remaining HTML to the lot and you will have the whole lot.

I dont see the point myself as you will be using a non standard script engine when you can use IIS for free.


JustinWillisAuthor Commented:
Thanks for your response Voodooman, the idea behind the DIY webserver is so that I am not limited to which windows OS I am running it on, this also saves £££'s when it comes to licensing and cal's ect... also I want to be able to run it on laptops which usually dont take kindly to Windows 2003 Server etc without a bit of a driver fight.. also I am able to create log files exactly how I want them which may prove very usefull in future.  Laptop in bedroom cupboard etc..

Just want a bare bones web server, ASP support would be nice too but as you point out it would be non standard if I attempt to slap an engine together myself, also ASP has grown to be quite powerfull with many commands available, I imagine it would take a long time to get anywhere near a 100% compatible ASP engine going.

I am hoping some one has needed to do a similar thing before or that there is and existing engine/source which can be used, I am really suprised there is not a parser already in existance to generate html from asp which is likely to be an indicator that it is a pain in the butt to do! ;)

I will take a look at FastScript but I am doubtful it will be of help for this specific task.

This thread is still very young, I will leave it open a little longer before awarding u full points..

Justin Willis.
JustinWillisAuthor Commented:
Found this interesting related artical which basically says that asp.dll does all the work, IIS passes the ASP code to it and the html is returned ready to be sent back to client:

If I could only figure out how to use the dll file I would be sorted rather than reinventing the wheel and writing the whole damn thing again..

BigRatConnect With a Mentor Commented:
There is a book called "ASP Internals" by Jon Flanders :-

You'd need to get a copy (local library?) and read it, because handling the script engine is rather complicated.
JustinWillisAuthor Commented:

After hours of further hunting I believe I may have found the perfect solution!

This allows you to run vbs, js AND asp code CLIENT SIDE!! yipeeeee.
I ran the above code through my Internet Explorer client side and got the following result...

This is a test of ASP.

It seems to trick explorer into parsing the code the same way a web server woud normally, just have to make sure this works in Delphi ok which im sure it will.  Then I will have my own little web server for which I have full control over and can run vbs, js and asp, very cool.

Voodooman's comment was the most usefull but I cannot ignore BigRat's contribution also so will split the points according to effort and usefullness.

Thank god I don't have to write that damn engine from scratch, I think I would have just given up that being the case.

Thanks again guys,
Justin Willis.
All Courses

From novice to tech pro — start learning today.