david
david

Reputation: 1

How to split a string and count the parts?

How can I do the same as the following PHP snippet in JSP?

$to_len = count(explode(",",$to));

Basically, it splits a variable with the name to on delimiter , and then counts the parts.

Upvotes: 0

Views: 2235

Answers (1)

Bozho
Bozho

Reputation: 597204

Using JSTL functions:

${fn:length(fn:split(to, ','))}

Another way is through scriptlets, but it is not recommended - to.split(",").length()

Upvotes: 1

Related Questions