CGI Perl脚本将脚本和HTML(以及'content-type:text / html')字符串打印到浏览器而不是呈现它。怎么修?

时间:2016-04-25 16:11:05

标签: html perl tomcat7 cgi

我正在使用Apache Tomcat版本的版本apache-tomcat-7.0.65

我的脚本内容是: -

#!/usr/local/bin/perl
print "Content-type:text/html\r\n\r\n";
print <<within_html;
<html>
<head>
<title>TESTING</title>
</head>
<body bgcolor='#FFE4C4'>
<h2>HELLO WORLD</h2>
</body>
</html>
within_html

但我得到的输出如下: -

#!/usr/local/bin/perl print "Content-type:text/html\r\n\r\n"; print <  
HELLO WORLD
within_html 

我在web.xml中启用了servlet,如下所示: -

<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>
     <load-on-startup>5</load-on-startup>
</servlet>

<!-- The mapping for the CGI Gateway servlet -->
<servlet-mapping>
    <servlet-name>cgi</servlet-name>
    <url-pattern>/cgi-bin/*</url-pattern>

我确实将以下内容添加到了context.xml中

<Context privileged="true">

请帮我修复HTML输出非常感谢你提前帮助。

0 个答案:

没有答案