O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

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

Expressions become the argument to an out.print()

image with no caption
image with no caption

In other words, the Container takes everything you type between the <%= and %> and puts it in as the argument to a statement that prints to the implicit response PrintWriter out.

When the Container sees this:

<%= Counter.getCount() %>

It turns it into this:

out.print(Counter.getCount());

If you did put a semicolon in your expression:

<%= Counter.getCount(); %>

That would be bad. It would mean this:

image with no caption

Note

NEVER end an expression with a semicolon!

<%= neverPutASemicolonInHere %>

<%= becauseThisIsAnArgumentToPrint() %>

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