aspose file tools*
The moose likes JSP and the fly likes JSP bean and parameter question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP bean and parameter question" Watch "JSP bean and parameter question" New topic
Author

JSP bean and parameter question

Tiya Khambadkone
Ranch Hand

Joined: Sep 15, 2011
Posts: 52
In my JSP I am setting the value inside a variable :
<c:set var="cover" value="${param.cover}" />

This value gets set properly. It is either acover, bcover or ccover

I want it use it in the same jsp like :

${mybean.acover.lib}
OR
${mybean.bcover.lib}
OR
${mybean.ccover.lib}

depending on the ${cover} value.

I want something like :
${mybean.${cover}.lib}

What is the correct syntax ?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

${mybean[cover].lib}

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tiya Khambadkone
Ranch Hand

Joined: Sep 15, 2011
Posts: 52
ParseException: Encountered " "[" "[ "" at line 1, column 16.
Was expecting:
<IDENTIFIER> ...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18988
    
    8

Maybe I'm missing something, but why isn't it just

${mybean.cover.lib}

?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Tiya Khambadkone wrote:ParseException: Encountered " "[" "[ "" at line 1, column 16.
Was expecting:
<IDENTIFIER> ...

Then you did something wrong. Post your code. Don't make us guess!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Paul Clapham wrote:Maybe I'm missing something, but why isn't it just

${mybean.cover.lib} ?

That would assume the property cover is hard-coded, rather than a variable.

What you posted is equivalent to: ${mybean['cover'].lib}
Tiya Khambadkone
Ranch Hand

Joined: Sep 15, 2011
Posts: 52
that does not work too...

looks like it tries to find a property name 'cover' inside myBean.java and then throws an exception as it does not find.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Post. Your. Code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP bean and parameter question