挨踢的小胖 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 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退