why does my jsp page show the source code rather t

2020-05-02 13:16发布

问题:

So the .jsp page is an animated ad, it will do its animation then wait two seconds and redirect user to another page.

Everything seems to be working fine using my localhost but when we push the project out to stage(testing) environment, the jsp page would just display the source code rather than the animation that i wanted.

Any ideas on why this could happen?

Here is my code:

   <filter>
        <filter-name>SplashPage</filter-name>
        <filter-class>com.pinksheets.common.web.filter.SplashPageFilter</filter-class>
    </filter>

    <filter>
        <filter-name>RunAd</filter-name>
        <filter-class>com.pinksheets.common.web.filter.SplashAdFilter</filter-class>
    </filter>


    <filter-mapping>
        <filter-name>RunAd</filter-name>
    <url-pattern>/home</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>SplashPage</filter-name>
        <url-pattern>/splash</url-pattern>
    </filter-mapping>

The .jsp page is just a regular page with a short animation

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta http-equiv="X-UA-Compatible" content="chrome=1">
        <meta name="viewport" content="user-scalable=yes, width=900px" />
        <title>New Security</title>           
    </head>
    <body>
        <div style="margin: auto; width: 900px">
        <div id="otcani2_hype_container" style="position: relative; overflow: hidden; width: 900px; height: 650px;">
        <script type="text/javascript" src="splashPage/otcani2_hype_generated_script.js?42496"></script>
            </div>
            <!-- end copy -->
        </div>
    </body>
</html>

回答1:

So, the JSP is not parsed at all? Is it only that particular JSP or does it also affect all other JSPs?

At least, this kind of problem can have 2 common causes:

  1. The servletcontainer's builtin JspServlet was not invoked during the HTTP request. It's by default configured on an URL pattern of *.jsp (and *.jspf and *.jspx). You need to make sure that your JSP file has really the .jsp extension and that you haven't overriden it in your webapp's web.xml. But this problem would then have affected all JSPs in your webapp and not only a particular one.

  2. There's a proxy server (like Apache HTTPD with mod_jk) in front of JBoss server which is not properly handling the HTTP request in question. It has loaded the JSP straight from JBoss' deploy folder instead of proxying (passing) the whole HTTP request to it. This is an issue which the responsible serveradmin has to look at. Contact him/her when you're unsure.



回答2:

I ran into a similar problem recently on Tomcat, and our problem was that we used a web.xml where JSP was disabled in Tomcat's web.xml.



标签: jsp jboss