`
newton21012915
  • 浏览: 59293 次
  • 性别: Icon_minigender_1
  • 来自: 长春
社区版块
存档分类
最新评论

Tomcat6 调用C/C++的cgi配置

阅读更多
context.xml
<Context privileged="true">

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
	
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
         on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->
</Context>

要加上privileged="true",否则tomcat启动报错,Servlet of class org.apache.catalina.servlets.CGIServlet is privileged and cannot be loaded by this web application
web.xml
    <servlet>
        <servlet-name>cgi</servlet-name>
        <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
        <init-param>
          <param-name>debug</param-name>
          <param-value>0</param-value>
        </init-param>
        <init-param>
          <param-name>cgiPathPrefix</param-name>
          <param-value>WEB-INF/cgi</param-value>
        </init-param>
        <init-param>
          <param-name>executable </param-name>
          <param-value>cmd /c </param-value>
        </init-param> 
        <load-on-startup>5</load-on-startup>
    </servlet>


C++代码
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{  
	cout<<"Content-type:text/html"<<endl<<endl;
	cout<<"Hello,World!";
	return 0;
}

编译后放在WEB-INF/cgi下。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics