Why is it strongly recommended that any JavaBean used within a JSP page belong to a named package?
Govind Seshadri It is advisable that any bean used within a JSP page belongs to a named package. A Java class that does not use a package statement ends up in the so-called unnamed package. The servlet class generated from the JSP page is, however, typically assigned to a named package. If you try to refer to a class in the unnamed package from a class in a named package, Java cannot find the class unless you explicitly use an import statement to import it. In a JSP page that means you must use both a page directive to import the class, and the <jsp:useBean> action to make it available:
<%@ page import="FooBean" %> <jsp:useBean id="foo" class="FooBean" />If the bean is part of a named packed, the <jsp:useBean> action is all you need:
<jsp:useBean id="foo" class="com.bar.FooBean" />