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

x
?
Solved

Convert ASP output to static HTML file

Posted on 2003-03-01
6
Medium Priority
?
276 Views
Last Modified: 2008-03-06
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.
0
Comment
Question by:d224
[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
6 Comments
 
LVL 7

Expert Comment

by:lavinder
ID: 8047260
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
 

Author Comment

by:d224
ID: 8047277
Hi lavinder
It's great, but I want redirect existing asp output to text file.
0
 
LVL 7

Expert Comment

by:markhoy
ID: 8047756
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 7

Expert Comment

by:lavinder
ID: 8055426
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
 
LVL 10

Accepted Solution

by:
apollois earned 800 total points
ID: 8055564
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
 
LVL 58

Expert Comment

by:Gary
ID: 9352519
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

721 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