uCosminexus Application Server, Web Container Functionality Guide

[Contents][Glossary][Index][Back][Next]

2.3.7 Implicitly importing the import attribute of the page/tag directive

According to the JSP specifications, the following classes are imported implicitly while compiling JSP:

If you use the functionality for implicitly importing the import attribute of the page/tag directive, you can implicitly import any desired class besides those described above.

Organization of this subsection
(1) How to specify the classes to be imported implicitly
(2) Output order of the import statements
(3) Notes

(1) How to specify the classes to be imported implicitly

This subsection describes how to specify the functionality for implicitly importing the import attribute of the page/tag directive. You can use the functionality for implicitly importing the import attribute of the page/tag directive when compiling JSP in a J2EE server, or when compiling JSP by the cjjspc command.

Specify the class to be imported implicitly with a fully qualified class name or with the "package name.*". When specifying multiple class names, use a comma (,) to demarcate two class names. When you specify a class name that does not exist or a class name with an invalid class path, the KDJE39143-E message is output during JSP compilation.

(2) Output order of the import statements

The order of the import statements output in the java file during JSP compilation is as follows:

  1. Import statement of classes specified in JSP specifications
    • java.lang.*
    • javax.servlet.*
    • javax.servlet.jsp.*
    • javax.servlet.http.*
  2. Import statement of the class specified in the import attribute of the page/tag directive
  3. Import statement of the class specified in the functionality for implicitly importing the import attribute of the page/tag directive

(3) Notes

(a) JSP file for which JSP pre-compilation is performed by the cjjspc command

The functionality for implicitly importing the import attribute of the page/tag directive operates during JSP compilation. When JSP pre-compilation is performed by the cjjspc command, the class specified in the webserver.jsp.additional.import.list key of the Easy Setup definition file is not imported implicitly to the Web application for which JSP pre-compilation is performed. Therefore, to perform JSP pre-compilation by the cjjspc command, specify the -addimport option in the cjjspc command and then perform JSP pre-compilation for the Web application, when using the functionality for implicitly importing the import attribute of the page/tag directive.

(b) When multiple Web applications exist in a J2EE server

The class specified in the webserver.jsp.additional.import.list key of the Easy Setup definition file is enabled for all Web applications in the J2EE server for which JSP pre-compilation is not performed by the cjjspc command. If you want to specify a different class for each Web application, specify the -addimport option in the cjjspc command, and then perform JSP pre-compilation for the Web applications.

(c) Recompiling after JSP pre-compilation

When all the below conditions are satisfied, the KDJE39143-E message is output during recompilation. Therefore, when using a Web application for which JSP pre-compilation is performed by specifying the -addimport option in the cjjspc command, specify the same class name as the one specified in the -addimport option of the cjjsps command in the webserver.jsp.additional.import.list key of the Easy Setup definition file.

(d) When a class name that already belongs to another class is specified

When the class name specified in the functionality for implicitly importing the import attribute of the page/tag directive duplicates a class name within the package to be imported that is specified in the JSP specifications, or the class name specified in the import attribute of the page/tag directive, a compilation error occurs during JSP compilation, and the KDJE39143-E message is output.

An example when a compilation error occurs during JSP compilation is described below. Note that in the example, the following class names must exist as a prerequisite:

When import class names from different packages overlap

An example is described below.

For the following specification contents, when an attempt is made to import classes with the same name from multiple packages, an error occurs during JSP compilation.

Type of file Specification contents
JSP file <%@page import="packageA.classA" %>
Easy Setup definition file webserver.jsp.additional.import.list=packageB.classA
When the import source package of the class used in a JSP file cannot be identified

An example is described below.

For the following specification contents, whether the classA used in the JSP file is packageA.classA or packageB.classA cannot be identified and an error occurs during JSP compilation.

Type of file Specification contents
JSP file <%@page import="packageA.* " %>
<% System.out.println(classA.method1()); %>
Easy Setup definition file webserver.jsp.additional.import.list=packageB.*