O'Reilly logo

MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL by James Turner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How Does JSP Work

To begin, let's look at the world's simplest JSP page, our version of the infamous “Hello World” program (see Listing 1.1).

Listing 1.1. HelloWorld.jsp
<HTML>
 <HEAD><TITLE>Hello World!</TITLE></HEAD>
 <BODY>Hello World!</BODY>
</HTML>

Okay, I can hear the screams of protest already. “That isn't JSP—that's plain old HTML. What are you trying to pull? I want my money back!”

It might look like innocent HTML, and if you put it into a .html file on a Web server, it would be delivered as straight HTML. But look what happens to this innocent little snippet in Listing 1.2 if you put it into a .jsp file instead.

Listing 1.2. HelloWorld as Java
 package org.apache.jsp; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required