0

I have the following jstl combine with jsp scriplet:

I can used

it doesn't give me an error about variable inventory not defined.

But when I used inside the loop for the scriplet:

It gives me an error "inventory" cannot be resolved.

Any help or hint would be greatly appreciated it!!

user1272936
  • 299
  • 1
  • 4
  • 15

1 Answers1

2

The var attribute variable is created in the page scope. To access that with a scriptlet, assuming the type of your variable is Inventory, use:

Inventory inventory = (Inventory) pageContext.getAttribute("inventory");

See also:

But, it's better to not use scriptlets and use EL instead. See:

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102