本节教程引用一个测试服务器,这个测试服务器可以执行cgi接口。它使得我们可以更好理解cgi的工作原理。
如果你对这个例子感兴趣的话,你可以到http://hoohoo.ncsa.uiuc.edu/cgi-bin/exam.txt.cgi下载。
为了得到更多的cgi脚本,你可以到ftp://ftp.ncsa.uiuc.edu/web/httpd/unix/ncsa_httpd/cgi/下载的cgi脚本档案。
以下是一个cgi脚本的请求,它没有额外的路径信息以及没有查询:
http://hoohoo.ncsa.uiuc.edu/cgi-bin/exam.cgi
下面是带有额外路径的信息没有查询的cgi脚本请求:
http://hoohoo.ncsa.uiuc.edu/cgi-bin/exam.cgi/extra/path
如果没有路径信息,而有一个isindex查询,其cgi脚本请求应该是如下:
http://hoohoo.ncsa.uiuc.edu/cgi-bin/exam.cgi?query
下面是具有额外路径信息和isindex查询的cgi脚本查询:
http://hoohoo.ncsa.uiuc.edu/cgi-bin/exam.cgi/extra/path?a+query
在这个例子中,你需要一个支持html表单的浏览器。如果你想使用get方法来发送一个表单请求,而没有额外的路径信息,你可以使用以下代码:
<form action=http://hoohoo.ncsa.uiuc.edu/cgi-bin/exam.cgi method=get><input
type=checkbox value=on name=button> press me.
<p><input type=submit value=submit>
<p></form>
如果你想使用post方法来发送一个表单请求,而没有额外的路径信息,你可以使用以下代码:
<form action=http://hoohoo.ncsa.uiuc.edu/cgi-bin/exam.cgi method=post><input
type=checkbox value=on name=button> press me.
<p><input type=submit value=submit>
<p></form>
如果你想使用post方法来发送一个表单请求,并带有额外的路径信息/pruple,你可以使用以下代码:
<form action=http://hoohoo.ncsa.uiuc.edu/cgi-bin/exam.cgi/purple method=post><input
type=checkbox value=on name=button> press me.
<p><input type=submit value=submit>
<p></form>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器