When I try load *.jsp files, I see the source code of each JSP files in my browser, what is wrong?

Ivo Limmen

You can only load a JSP file through you webserver, if you open them by hand the browser will show the Java code inside the HTML file. By starting you Tomcat (or an other JSP / Servlet engine) the server will compile the JSP and will send a 'normal' HTML file to you browser that will behave as you coded it in the Java code between the HTML tags.

If you did start the JSP / Servlet engine but you are still seeing the JSP code then the server mappings are wrong. The engine does not know that it should compile the JSP file that is requested and simple shows the complete file. In the Tomcat engine this is specified in the server.xml file in the conf directory. The server.xml should contain this:

This piece of XML tells the Tomcat server that it must use the JspServlet class when a JSP file is requested. The JspServlet then checks if the JSP file is compiled or not.