Finding the Java Sources

As soon as you start developing JSP, you'll run into your first Java error (either a syntax error or an exception). Because JSP is executing Java code instead of the raw JSP source, it can be tricky to figure out exactly where the error occurred.

Let's look at both types of errors and see how to track them down. First, let's create a JSP file with a simple syntax error in Listing 1.6.

Listing 1.6. fiveloop_syntax.jsp
<HTML>
 <HEAD><TITLE>Hello World!</TITLE></HEAD>
 <BODY>
 <%
   int i = 0;
   while (i++ < 5) {
 %>
  Hello World! Loop #
  <% out.print(j); %>
  <br>
 <% }  %>

</BODY>
</HTML>

Luckily, syntax errors generate fairly easy-to-read error messages and even print out the offending line so that you can locate it in your sources ...

Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.