As we all know, asp technology is the main technology for our web programs based on the internet/intranet platform. In asp applications, we generally use two scripting languages: vbscripts and javascripts. However, scripting language is a non-compiled language, and the web programs developed by it have inherent problems in terms of security, execution efficiency and scalability. Therefore, when developing web systems, we generally use high-level languages to write ASP execution bodies, and then use scripts to The language serves as the connection code to call the asp execution body to perform access. In this regard, since ASP technology was introduced by Microsoft, we generally use VB or VC, so how can Delphi programmers achieve it?
In this regard, the author has recently realized the web programming of ASP technology in the Delphi environment through the information of inrpisre. Here is an introduction as follows:
1. Create a new acdiveX DLL project PRoject1 in the delphi environment, then create an ASP object through delphi's Active Server Object, and fill in the name of the created object MyAspObject in its coClassName.
2. Use the type Library to create a method MyAspRequest for the newly created MyAspObject object that will be called by the script language.
3. Since the ASP object just created inherits from TASPObject, we can directly use the asp object in method creation. Now fill in the code for the Asp object we created as follows:
produce TMyAspObject.MyAspRequest;
begin
repsonse.write('<p>Your name is:');
repsonse.write(request.form.item['Name']);
repsonse.write('</p>');//Read the user name from the web page to be created//
repsonse.write('<p>Your job is:');
repsonse.write(request.form.item['work']);
repsonse.write('</p>');//Read the user work from the web page to be created//
repsonse.write('<p>The development tool you use:');
if(request.form.item['delphi'].count>0)
repsonse.write('delphi');
if(request.form.item['bcb'].count>0)
repsonse.write('c++ Builder');//Determine the development tools used by the user//
repsonse.write('</p>');
repsonse.write('<p>Your identity:');
repsonse.write(request.form.item['Identity']);
repsonse.write('</p>');//Read the user's identity//
end;
4. Compile the program and register it as PMyAspObject.dll file in delphi.
5. Write the ASP script language file MyAsp.asp for connection
<%@language=jscript %>
<HTML>
<BODY>
<title>This is an ASP object created with delphi</title>
<center><h3>The content you fill in is as follows</h3></center>
<%
var myasp;
myasp=server.createobject(PMyAspObject.MyAspObject);
//Generate connection object//
myasp.MyAspRequest();//Call your own defined ASP object//
%>
</body>
</HTML>
6. Create the web page Myhtm.htm for display
<form action='localHost/shd/myasp.asp' method='post">
<h1 align='center">Please select</h1>
<P>Name: <input type='text' size=33 name="name"></p>
<P>Work: <input type='text' size=33 name="work"></p>
<P>Development tools: <input type='checkbox' name='delphi' value="on">delphi
<input type='checkbox'name='bcb'value="on">c++ Builder</p>
<p>Your identity:</p>
<p><select name="identity" size="1">
<option>Student</option>
<option>Technician</option>
</select></p>
<p><input type="submit" name="mysubmit" value="Submit">
</form>
7. Then put Myhtm.htm and myasp.asp in the shd directory of your personal web server to browse and test.
Web page renderings
ASP renderings
The above program is implemented in pwin98 ME and delphi5.0 Enterprise.