File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP page directive -- multi import attributes?

 
Joe Allen
Ranch Hand
Posts: 93
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the following correct (with multi import attributes)?

<%@ page import=”java.util.List” import=”java.util.ArrayList” %>
 
Prajakta Acharya
Ranch Hand
Posts: 138
Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think so.

You can place multiple imports as comma seperated in a single import attribute.
 
Joe Allen
Ranch Hand
Posts: 93
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer B (<%@ page import=”java.util.List , java.util.ArrayList” %> ) is correct and the answer C is not correct.
 
Joe Allen
Ranch Hand
Posts: 93
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. It must be an errdata in the mock exam.
 
Joe Allen
Ranch Hand
Posts: 93
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 440
Eclipse IDE Hibernate Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic