Page 1 of 1

About Question enthuware.jwpv6.2.981 :

Posted: Mon Jan 16, 2012 4:29 pm
by Ciprian Mihalache
<%@ page import="java.util.*" import="java.text.*"%>
import is an attribute and can occur only once inside a page directive.
Are you sure about this? On my PC I have Tomcat and it works like a charm. The documentation states about the import :
There shall be only one occurrence of any attribute/value pair defined by this directive in a given translation unit, unless the values for the duplicate attributes are identical for all occurrences. The import and pageEncoding attributes are exempt from this rule and can appear multiple times.
Multiple uses of the import attribute are cumulative (with ordered set union semantics).
but indeed is not very specific if multiple import can be defined in a single page directive, or in multiple directives in the same page.
An old Tomcat bug address the same issue: https://issues.apache.org/bugzilla/show_bug.cgi?id=4022
Anyway, the explanation as it is is not correct.

Re: About Question enthuware.jwpv6.2.981 :

Posted: Tue Jan 17, 2012 7:48 am
by admin
Technically, an import attribute can occur multiple times in a page. It is clear that it is valid to have multiple page directives with import attribute. However, it is not clear from the specification whether import attribute can occur multiple times within the same page directive. Ideally, specifying the same attribute twice in the same directive should cause translation error. (Which is what the tomcat bug report mentions as well.)

The explanation has been modified accordingly.

thank you for your feedback!