context.xml
要加上privileged="true",否则tomcat启动报错,Servlet of class org.apache.catalina.servlets.CGIServlet is privileged and cannot be loaded by this web application
web.xml
C++代码
编译后放在WEB-INF/cgi下。
<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下。