挨踢的小胖 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 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)