How do I parse ASP code to HTML?

Posted on 2004-11-10
Last Modified: 2010-04-05
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
Question by:JustinWillis
    LVL 5

    Accepted Solution


    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.


    LVL 1

    Author Comment

    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.
    LVL 1

    Author Comment

    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..

    LVL 27

    Assisted Solution

    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.
    LVL 1

    Author Comment


    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    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…
    Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    759 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

    13 Experts available now in Live!

    Get 1:1 Help Now