This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JSP page directive -- multi import attributes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JSP page directive -- multi import attributes?" Watch "JSP page directive -- multi import attributes?" New topic
Author

JSP page directive -- multi import attributes?

Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
Is the following correct (with multi import attributes)?

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

"There are no dumb questions" quoted from HFSJ. "To err is human; to forgive is divine"
OCPJP 6, OCEJWCD 6
Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138

I dont think so.

You can place multiple imports as comma seperated in a single import attribute.


Regards,
Prajakta
Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
Thanks for responding. I don't think so either. It is in Nikos mock exam. See below:

8.Which of the following are syntactically valid? (2 correct answers)
1.<%@ page import=”java.util.List : java.util.ArrayList” %>
2.<%@ page import=”java.util.List , java.util.ArrayList” %>
3.<%@ page import=”java.util.List” import=”java.util.ArrayList” %>

Correct answer: 8.b, c (2,3)
Fabian Angy
Ranch Hand

Joined: Oct 27, 2008
Posts: 90
Answer B (<%@ page import=”java.util.List , java.util.ArrayList” %> ) is correct and the answer C is not correct.


SCJP 5
Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
Thanks. It must be an errdata in the mock exam.
Joe Allen
Ranch Hand

Joined: Nov 14, 2012
Posts: 93
Actually, <%@ page import=”java.util.List” import=”java.util.ArrayList” %> is considered "technically correct". I found this out when I was doing Enthuware tests. See the explanation below:

"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. However, some containers are forgiving and accept it as valid.

Here is an old bug report for Tomcat that you might find interesting : https://issues.apache.org/bugzilla/show_bug.cgi?id=4022"

The above is quoted from Enthuware.
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Joe wrote: Here is an old bug report for Tomcat that you might find interesting : https://issues.apache.org/bugzilla/show_bug.cgi?id=4022"


Very interesting indeed. Thank you for the share.


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
 
jQuery in Action, 2nd edition
 
subject: JSP page directive -- multi import attributes?
 
Similar Threads
Which of the following are valid JSP code fragments?
Http status 500
import
JSP Single Threaded model ???
Help! Where to put a bean class