JSP显示源代码而不是执行 [英] JSP displaying source code instead of executing

查看:460
本文介绍了JSP显示源代码而不是执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jsp的新手,遇到了一些麻烦。最初,jsp文件和相关的java类是在测试Tomcat服务器上构建和测试的。现在,他们已经转换到我认为是相同设置的另一台服务器(除了它现在是linux而不是windows)。但是当访问jsp页面时,显示源代码而不是实际执行的jsp。我已经google了一段时间但没有成功。

I'm new to jsp and have ran into some trouble. Initially, the jsp file and associated java classes were built and tested fine on a test Tomcat server. Now, they've been transitioned to another server of what I believe is the same setup (except it's linux now instead of windows). But when the jsp page is accessed the source code is displayed instead of the jsp actually executing. I've googled for a while but received no success.

这是我正在测试的jsp文件的代码:

Here is the code of the jsp file I am testing:

<HTML>
<BODY>
Hello!  The time is now <%= new java.util.Date() %>
</BODY>
</HTML>

以下是导航到页面时我在浏览器中看到的内容:

And here is what I see in my browser when navigating to the page:

 Hello! The time is now <%= new java.util.Date() %> 

页面的来源是示例文件中输入的确切代码:

The source of the page is the exact code that is typed in the example file:

<HTML>
<BODY>
Hello!  The time is now <%= new java.util.Date() %>
</BODY>
</HTML>

服务器似乎正在运行。以下是我从Firebug获得的回复标题:

The server appears to be working. Here are is the response headers I obtained from Firebug:

Date    Sat, 15 Jan 2011 20:53:24 GMT
Server  Apache/2.2.3 (CentOS)
Last-Modified   Sat, 15 Jan 2011 02:20:18 GMT
Etag    "b385d8-55-499d931205c80"
Accept-Ranges   bytes
Content-Length  85
Content-Type    text/html; charset=UTF-8

我原以为这个页面可以解决问题,因为我没有引用我正在使用的jsp文件,甚至我的web.xml文件中的以下代码片段在WEB-INF文件夹中:

I had thought that this page might solve the problem since there was no reference to the jsp file I was using or even the following snippets in my web.xml file in the WEB-INF folder:

<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
        <param-name>logVerbosityLevel</param-name>
        <param-value>WARNING</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.jsp</url-pattern>
</servlet-mapping>

我尝试插入这些行并重新启动Tomcat,但没有成功。任何想法?

I tried inserting these lines and restarting Tomcat, but no success. Any ideas?

推荐答案

从回复标题中:


服务器Apache / 2.2.3(CentOS)

Server Apache/2.2.3 (CentOS)

这不是由 Apache Tomcat ,但是通过 Apache HTTPD 。您根本没有将它部署到Tomcat。

This is not served by Apache Tomcat, but by Apache HTTPD. You did not deploy it to Tomcat at all.

这篇关于JSP显示源代码而不是执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆