• Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom tag Qs  RSS feed

 
Umakanth Godavarthy
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came across these Qs from one of the mock exams...
Q1.Consider the following taglib directive in a JSP page. Which of the following JSP syntax could be valid? [Check all correct answers]
<%@ taglib uri="/WEB-INF/tlds/myTLD.tld" prefix="custom" %>
1. <custom:getResource/>
2. <custom:setRandom()/>
3. <Custom:getResource/>
4. <custom:getResource></custom:getResource>
5. taglib is incorrectly defined.
Ans:1,4
My Ans: 1,2,4 (2 is for EL-functions)

Q2.Consider that all tags are declared in the deployment descriptor as having an empty body content. Which of the following are valid custom tag declarations within a JSP page? [Check all correct answers]

1. <p:tag/>
2. <p:tag color="green"/>
3. <p:tag color="green"><p:tag1/></p:tag>
4. <util:tester suite="1"> </util:tester>
5. <p:tag color="green"></p:tag>

Ans:1,2,5
My Ans: 1,2,4,5
Can't we have white spaces between the starting and closing tags and still be treated as empty tags.
-Thanks

[ December 09, 2005: Message edited by: Umakanth ]
[ December 09, 2005: Message edited by: Umakanth ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 1:
EL-Function should be used 'EL way' : ${custom:setRandom()}

Question 2:
plz refer to "JSP.1.3.4 Empty elements", to understand what an empty tag is.
 
Umakanth Godavarthy
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1st one is a blunder..
I think i've been studying too much....

Thanks for the reference :roll:
[ December 09, 2005: Message edited by: Umakanth ]
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From spec:


<foo><!-- a comment --></foo>


Why is this not a valid empty tag. It looks very similar to the previous comment tag.


<x:foo><%-- any comment --%></x:foo>


Is it because it doesn't have a prefix?
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Umakanth", welcome to the ranch. Please take a few moments to read the Javaranch naming policy. We try to be friendly around here but we do have our rules, and not following the naming policy can result in having your account deleted.

We'd prefer to keep you with us.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12465
43
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that Marc's was your second warning.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!