PrecisionPete
PrecisionPete

Reputation: 3401

EL and Scriptlets how to get pageContext.getAttribute children?

Is there an easy way for a scriptlet to access a field from a result as below? What should it look like?

${item.options} is not written as <%= pageContext.getAttribute("item.options") %>

I know I can set a new pageContext variable and access that. But I thought there might be a more elegant way...

I know that scriptlets are not ideal, but I am just prototyping.

Upvotes: 2

Views: 5817

Answers (1)

BalusC
BalusC

Reputation: 1108557

It's PageContext#findAttribute() and you should get the ${item} directly instead of its options property which is not stored as a separate attribute or something. Given that it's an instance of class Item, here's how you can get it:

Item item = (Item) pageContext.findAttribute("item");

Then just call the getOptions() method on it.

See also:

Upvotes: 3

Related Questions