I have the following JSP:
<%@ page import=\"foo.*\" %>
The page count is
Classes in the default package are not visible to classes which are by itself inside a package. You must put the class in a package whenever you want to import it in another class which is by itself inside a package. Technically, when JSP files are compiled, the container will autogenerate a .class
file which is by itself inside a package. So you cannot import classes from the default package in the JSP.
So, whenever you want to be able to reuse a class anywhere, it has to be placed in a concrete package, not in the default package. As an exercise, create two classes yourself, one which is inside a package and other which is not inside a package. Now, inside the one with package, try to import
and use the one without package. You'll see that it's not possible and the code won't compile. The servletcontainer encounters exactly the same problem "under the hoods".
Unrelated to the concrete problem: writing raw Java code in JSP files is a poor practice. Consider learning and using servlets.