As a built-in ASP object, we finally learn server objects.
Server objects use HTML encoding, URL encoding, and webpage redirection and transmission.
?
Open VB6 and create an ActiveX dll project. Change project name to fcom and class name to fz6
Reference the "Microsoft Active Server Pages object" Object Library.
Create two component events: onstartpage and onendpage
Create a reference of the scriptingcontent class in the event onstartpage.
Instantiation class scriptingcontent.
?
The Code is as follows:
Option explicit
'Object Declaration
Dim myresponse as response
Dim myrequest as request
Dim myapplication as application
Dim myserver as server
Dim mysession as session
?
??? 'This event is triggered when the component is created.
Public sub onstartpage (myscriptingcontent as scriptingcontext)
???? 'Instantiate the object
???? Set myresponse = myscriptingcontent. Response
???? Set myrequest = myscriptingcontent. Request
???? Set myserver = myscriptingcontent. Server
???? Set myapplication = myscriptingcontent. Application
???? Set mysession = myscriptingcontent. Session
End sub
?
??? 'This event is triggered when the component is destroyed.
Public sub onendpage ()
???? 'Destroy object
???? Set myresponse = nothing
???? Set myrequest = nothing
???? Set myserver = nothing
???? Set myapplication = nothing
???? Set mysession = nothing
End sub
?
Public sub showhtml (byval strhtml as string)
??? Myresponse. Write myserver. htmlencode (strhtml)
End sub
?
Public sub showurl (byval strurl as string)
??? Myresponse. Write myserver. urlencode (strurl)
End sub
?
Public sub executeurl ()
??? Myserver. Transfer "fz5.asp"
End sub
?
The system automatically registers the DLL file.
Otherwise, manually register regsvr32 F:/test/fcom. dll.
?
Test
Open visual interdev6.0 and generate a fz6.asp File
Dim OBJ
Set OBJ = server. Createobject ("fcom. fz6 ")
OBJ. showhtml"
Test it"
Response. Write"
"
Response. Write "name ="
OBJ. showurl ("Mrs tornado ")
Response. Write "& age ="
OBJ. showurl ("26 ")
?
Response. Write"
"
Call obj. executeurl ()
%>
?
Configure the virtual directory and run the fc6.asp file in IE.
Test it.
Name = Mrs + % C1 % fa % be % ed % B7 % E7 & age = 26
You can use IE to view the source file for HTML encoding.
?
?
?
ASP built-in objects will be introduced here for the time being, and we will continue to learn later.
You can also learn the attributes and methods that are not introduced.