挨踢的小胖 2012-11-06 20:10
浏览 341
已采纳

Tomcat 6如何配置C/C++的cgi

在web.xml的配置:

cgi
org.apache.catalina.servlets.CGIServlet

debug
0


passShellEnvironment
true


cgiPathPrefix
WEB-INF/cgi-bin


executable
cmd /c



clientInputTimeout
100

5

<servlet-mapping>
    <servlet-name>cgi</servlet-name>
    <url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>

在context.xml的配置:

cgi
/cgi-bin/*

调用cgi的网页代码:

<!Sample web page for illustrating CGI>
<!Author: M. Liu, 9/15/01>


A Web Page that invokes a Web script

The Web Page illustrates the use of a Web script

This page contains an action tag which specifies a Web script. Upon retrieving this page from the Web server, the browser processes the contents and, when the SUBMIT button is pressed, requests the server to run the script or program specified with the action tag.
The script o program is either a run-script written in a script language such asa Perl, or an executable generated from a source program written in a language such as C/C++



Press to submit your query.


cgi运行不了。求大神指导。
[img]http://dl.iteye.com/upload/attachment/0076/2560/350574ac-02df-3df6-b111-267a895dcb22.png[/img]

  • 写回答

1条回答 默认 最新

  • blogzhoubo 2012-11-06 23:05
    关注

    如果用c或者c++的话,应该编译成hello.exe这样的可执行文件,然后

    改成

    然后在浏览器访问 http://localhost:8080/cgi-bin/hello.exe

    此外,因为hello.exe本身就是可执行程序,所以executable的值配置成空也没问题

    executable

    报错的原因应该是windows不知道hello.cgi应该用什么程序打开(没有设置cgi的文件关联),也就是不识别cgi扩展名。直接在windows的cmd窗口中执行cmd /c hello.cgi的话,会直接弹出对话框,让你选择用什么程序打开hello.cgi文件。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法