Convert ASP output to static HTML file

I have asp file content static html and asp code.
I want to be able save output of this file to static html file on my server.
Please help.
d224Asked:
Who is Participating?
 
apolloisConnect With a Mentor Commented:
d224,

>>>I have asp file content static html and asp code.
I want to be able save output of this file to static html file on my server.<<<

In order to save the HTML code generated by the ASP processor, you will need to use XMLHTTP.  See the example and references below.  If you have any follow-up questions, feel free to  post here.

Best Regards,
>apollois<


~~~~~~~~~~~~~~~~~~~~~
Here is an example:
~~~~~~~~~~~~~~~~~~~~~

==============================================================
<%@ Language="VBScript" %>
<%
     Const ForWriting = 2
     Const ForReading = 1
     Const OVERWRITE = True
     
     DIM objFSO
     DIM objTextStream
     Dim objSvrHTTP
     Dim strHTML
     
     Set objSvrHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
     objSvrHTTP.open "GET", "http://www.yoursite.com/yourfile.asp", false

     objSvrHTTP.send

     strHTML = objSvrHTTP.responseText
     strFileName = "Yourfile.htm"

     '--- NOW USE FILE SYSTEM OBJECT TO SAVE TO FILE ----
     
     Set objFSO = CreateObject("Scripting.FileSystemObject")
     
     '--- OPEN TEXTSTREAM OBJ FOR WRITING, OVERWRITE EXISTING FILE (IF ANY) ---
     
     Set objTextStream = objFSO.OpenTextFile(Server.MapPath(strFileName), _
                                   ForWriting, OVERWRITE)
     
     '--- WRITE STRING TO FILE ---
     objTextStream.Write strHTML
     
     '--- CLOSE AND RELEASE OBJECTS ---
     objTextStream.Close
     set objTextStream = nothing
     set objFSO = nothing

%>
=================================================================


~~~~~~~~~~~~~~~~~~~~~~~~~
For more info, please see:
~~~~~~~~~~~~~~~~~~~~~~~~~

Frequently Asked Questions about ServerXMLHTTP
http://support.microsoft.com/default.aspx?scid=kb;EN-US;290761

ServerXMLHTTP 4.0 Object Documentation
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/xml_obj_iserverxmlhttprequest_5115.asp

MSXML 4.0 SDK Documentation
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/sdk_intro_6g53.asp?frame=true

ServerXMLHTTP 4.0 Example and Docs - PerfectXML.com
http://www.perfectxml.com/msxmlHTTP.asp


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here's where to get the latest version
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MSXML 4.0 SP 1 (Microsoft XML Core Services)
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=0CDD34BF-50EA-4238-846B-243C58FF224A

Microsoft XML Core Services 4.0 SP1
http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/766/msdncompositedoc.xml


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TROUBLESHOOTING
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Proxy Configuration Utility Must Be Run for ServerXMLHTTP to Work
http://support.microsoft.com/default.aspx?scid=kb;EN-US;289481

Download Proxycfg.Exe From Following MSDN Web Site At:
http://msdn.microsoft.com/code/sample.asp?url=/msdn-files/027/001/468/msdncompositedoc.xml

0
 
lavinderCommented:
hi

 try this

dim fso,strm,i

set fso=server.createobject("scripting.filesystemobject")
set strm=fso.createtextfile(server.mappath("output.htm"),true)
strm.writeline "<html><head></head><body>"
strm.writeline "<ol>"
for i=1 to 10
 strm.writeline "<li>" & i & "</li>"
next
strm.writeline "</body></html>"
strm.close
set strm=nothing
set fso=nothing

cheers!!
0
 
d224Author Commented:
Hi lavinder
It's great, but I want redirect existing asp output to text file.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
markhoyCommented:
Then just direct your asp to the output stream, something like:

myBody = the asp code (you will need to concatenate your output as the asp generates it and then write it the FSO stream)

then

strm.writeline myBody

(as above).
0
 
lavinderCommented:
hi d224

 The code posted above is asp code, you can see that whatever output it is generating, is going to a static html file, you can send the output to html/text or asp file also. Existing asp output ? probably, i am unable to understand your requirement, please explain.

cheers!!
0
 
GaryCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Answer by apollois

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0
All Courses

From novice to tech pro — start learning today.