Paweł Adamski
Paweł Adamski

Reputation: 3415

How to use JSP EL insinde tag attribute

Is it possible to use EL expression inside tag attribute?

I wrote following code

<jsp:useBean id="beans" class="pl.adamski.heroku.Beans"/>
<jsp:useBean id="questions" class="${beans.questionManager}"/>

but it doesn't compile, I get following error:

The value for the useBean class attribute ${beans.questionManager} is invalid

Upvotes: 1

Views: 160

Answers (2)

seballos
seballos

Reputation: 250

According to the documentation the class attribute does not allow the EL

"class="package.class" Instantiates a bean from a class, using the new keyword and the class constructor. The class must not be abstract and must have a public, no−argument constructor. The package and class name are case sensitive." see Oracle docs

Upvotes: 1

6ton
6ton

Reputation: 4214

No, what you are attempting is not allowed. Try looking at the code generated from the tag lib and it will explain why this is not allowed. Check this

Upvotes: 1

Related Questions