Write the html code into the file and then generate the file in the .html format
<%
filename = test.htm
If Request (Body) <> THEN
set fso = server.createObject (scripting.filesystemObject)
set htmlwrite = fso.createtextFile (server.mAppath (FILENAME))
htmlwrite.write <html> <head> <Title> Request.form (Title) </Title> </Head>
htmlwrite.write <body> Output Title Content: Request.form (Title) <br/> Output Body Content: Request.form (Body) </body> </html>
htmlwrite.close
set fout = nothing
set fSO = Nothing
end if
%>
<FORM NAME = FORM METHOD = Post Action =>
<input name = title value = title size = 26>
<br>
<textarea name = Body> Body </Textarea>
<br>
<br>
<input type = submit name = submit value = generate HTML>
</form>
2. However, it is very inconvenient to generate the HTML file according to the above method. The second method is to use the template technology to replace the value of the special code in the template to the value accepted from the form or the database field to complete the template function; it will be final All the template code that has been replaced generates HTML files. This technology is more adopted. Most CMS uses this method.
template.htm '// template file
<html>
<head>
<Title> $ Title $ By JZXUE.com </Title>
</head>
<body>
$ Body $
</body>
</html> testmplate.asp '// generate HTML
<%
Dim fso, htmlwrite
DIM Strtital, Strcontent, Strout
'// Create a file system object
Set fso = server.createObject (scripting.filesystemObject)
'// Open the web template file and read the template content
Set htmlwrite = fso.opentextFile (server.mappath (template.htm))
Strout = f.readall
htmlwrite.close
strtital = generated webpage title
Strcontent = generated webpage content
'// Use real content to replace the mark in the template
Strout = Replace (Strout, $ Title $, StrTitle)
Strout = Replace (Strout, $ Body $, Strcontent)
'// Create a static page to be generated
Set htmlwrite = fso.createtextFile (server.mappath (test.htm), true)
'// Write into the web content
htmlwrite.writeLine Strout
htmlwrite.close
Response.Write generates a static page success!
'// Release the file system object
set htmlwrite = Nothing
set fSO = Nothing
%>