2 Minutes To Code (β Version)

JSP - 2 minute tutorial

Import Page Directive - How to import java packages

You would have noticed in earlier examples on jsp expressions and scriptlets that we used fully classified class name of java objects like java-util.Date.

This can get very cumbersome when many objects/classes are used. Jsp provides page directive import which functions the exact same way as the import statements of java classes. Multiple classes can be imported by using commas(,) or asterisk(*).

Let's see these in action below.
<%@ page import="java.util.Date" %>
<%@ page import="java.util.List,java.util.Set" %>
<%@ page import="java.sql.*" %>
		The current date is <%= new Date() %>
		<% List list = null; %>