JSP displaying source code instead of executing

See where it says "logVerbosityLevel" and "WARNING"? Change WARNING to DEBUG. You can also find your catalina.sh script and find your java command and make sure the flag -DDEBUG is included in the startup options.

Looking in your log with full debug mode on will tell you if there are any problems starting Tomcat on the new server.

For instance, you could have a missing depencency or a dependency conflict that isn't showing up with less informative logging levels.

Lastly, have you tried a simple JSP test page?

      <% out.println("Hello"); %>

If you put that in a JSP and try to load it, do you see the JSP or the output?

Have you tried using the Tomcat port in your request? Usually, this is 8080. I think one of the commentors mentioned that as a possibility.


From the response headers:

Server Apache/2.2.3 (CentOS)

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


I have just had this same problem, which is how I stumbled on this post. For me, it turned out that the issue was the difference between CATALINA_HOME and CATALINA_BASE. I think a lot of people don't realize this is two different places. On my Ubuntu, CATALINA_HOME was in /usr/share/tomcat6 but CATALINA_BASE was in /var/lib/tomcat6. It matters because you need to put your jsp files in CATALINA_BASE. So, in fact, I would say that Tomcat was not finding your code, even though your browser found the file and happily displayed it for you as it does other text files.

Hope this helps someone else who comes here with the same problem--it's my first attempt to post an answer on StackOverflow.

Tags:

Java

Tomcat

Jsp