Use the page directive to import packages
A directive is a way for you to give special instructions to the Container at page translation time. Directives come in three flavors: page, include, and taglib. We’ll look at the include and taglib directives in later chapters, but for now all we care about is the page directive, because it’s the one that lets you import.

To import a single package:

To import multiple packages:

Notice what’s different between the Java code that prints the counter and the page directive?
The Java code is between angle brackets with percent signs: <% and %>. But the directive adds an additional character to the start of the element—the @ sign!
If you see JSP code that starts with <%@, you know it’s a directive. (We’ll get into more details about the page directive later in the book.)
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access