• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EPractice Lab quiz 1 about delim in c:forTokens

 
Bartender
Posts: 2419
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


How many iterations occur when the "delims" attribute of the c:forTokens is not specified?

a. 0
b. 1
c. Either A or B
Choice C is correct
The "delims" attribute specifies the set of delimiters (the characters that separate the tokens in the string). If it is null, items are treated as a single monolithic token. Depending on whether the "items" attribute is null or not, <c:forTokens> iterates exactly 1 time or does not iterate.
Thus, choice C is correct while choices A and B are incorrect.


As I tried, if I don't put delim attribute for c:forToken, the JSP does not compile.
If I put delim="", the string is iterated exactly once and print the whole string out.
So, the answer can be either B or does not compile.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The delims attribute is the c:forToken is required. If omitted, it wouldn't compile.

Given the question as is, none of the answer choices are correct. A option D saying "won't compile" or "none of the above" will suit. Option B won't be correct.

However, have you tried
 
Himai Minh
Bartender
Posts: 2419
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Tsang,
I tried <c:forTokens var="token" items="...." delims=null >, but it does not compile. It wants me to put " " around the null.
Instead, I tried this. It delims by "n", "u" , "l"

The output is :


Str
ts, Spri
g, Hiber
ate, EJB

 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting result.
 
this llama doesn't want your drama, he just wants this tiny ad for his mama
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic