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() %>

Get Head First Servlets and JSP, 2nd Edition 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.