• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rtexprvalue

 
Paulo Marcio Brandi Rezende
Ranch Hand
Posts: 34
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HFSJ 1st, mock exam, we have this question (#12):

Given this tag handler class excerpt:

... [not necessary to understand]

and given this TLD excerpt:

21. <tag>
22. <name>worthless</name>
23. <tag-class>com.mycom.WorthlessTag</tag-class>
24. <body-content>empty</body-content>
25. <attribute>
26. <name>x</name>
27. <required>true</required>
28. <rtexprvalue>true</rtexprvalue>
29. </attribute>
30. </tag>

and given this complete JSP page:
1. <%@ taglib uri=�somevaliduri� prefix=�w� %>
2. <w:worthless x=�x� />
3. <w:worthless x=�<%=Boolean.TRUE.toString()%>� />
4. <w:worthless x=�y� />
5. <w:worthless x=�z� />

What output does the JSP generate?

Right answer:

C. xE trueE yE

My questions is:

In this way, I guess that <%=Boolean.TRUE.toString()%> and ${Boolean.TRUE.toString()} do exactly the same. Am I right?

The both work only if <rtexprvalue>true</rtexprvalue>?

Or the first option, <%=Boolean.TRUE.toString()%> works even with <rtexprvalue>false</rtexprvalue>?
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are mistaken with EL, as per I know while evaluating EL, first element is either implicit EL variable or must be a Bean,Array, List or Map.
so ${Boolean} --> Boolean is neither implicit nor it is Bean/Map in any of the 4 scopes.

so ${Boolean...} --> return Blank
so using of ${Boolean.TRUE.toString()} is ruled out.

<%= Boolean.TRUE.toString() %> will be evaluated during run time, so it can not be used with <rtexprvalue>false</rtexprvalue>

Please correct me if I am wrong.
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when you try it?
 
Paulo Marcio Brandi Rezende
Ranch Hand
Posts: 34
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sunny Jain,

You're right, I can not use ${Boolean.TRUE.toString()}, and ${Boolean.TRUE} evaluates to blank. I'm sorry for the mistake :roll:

About the use of <%= Boolean.TRUE.toString() %> with <rtexprvalue>false</rtexprvalue>, I tried it and doesn't work.

Thanks for all...
[ August 06, 2008: Message edited by: Paulo Rezende ]
 
Sandeep Bhandari
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<w:worthless x=�<%=Boolean.TRUE.toString()%>� />

clears that the value of x is <%=Boolean.TRUE.toString()%>. Now the actual value of this expression can be known only at request time by calling the toString method.

So it has to be true for rtexprvalue
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic