How do you import classes in JSP?

To import classes in a JSP (JavaServer Page) file, you can use the <%@ page import="package.class" %> directive.

For example, to import the java.util.List class, you can use the following directive:

<%@ page import="java.util.List" %>

You can also import multiple classes by separating them with a comma:

<%@ page import="java.util.List, java.util.ArrayList" %>

You can also import an entire package by specifying the package name followed by .*:

<%@ page import="java.util.*" %>

This will import all the classes in the java.util package.

Keep in mind that the import directive is only used to import classes that will be used in the JSP file. It does not actually include the classes in the compiled JSP file or in the resulting HTML output.

If you want to use classes that are not imported in the JSP file, you can fully qualify their names with the package name. For example:

java.util.List list = new java.util.ArrayList();