Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading A Javabean in JSTL  RSS feed

 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to do something like this:

<c:when test="${city == <jsp:getProperty name="contactData" property="city"/>}">

But I get an error:

/modifyContact.jsp(98,64) equal symbol expected

How can I read the contents of a bean in JSTL?
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, it appears I can access the Javabean directly by name is the JSTL:

<c:when test="${city == contactData.city}">

This works fine. Cool.

I am ok now.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, don't mix and match.

Also, correcting a bit of terminaology.

The JSTL is the tag set. For example, the <c:test> tag.

The EL (Expression language), is what's between the ${ and } delimiters.

Though they are closely aligned, they are not the same thing.
[ October 07, 2004: Message edited by: Bear Bibeault ]
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. So is it better to stick with EL over JavaBeans? They seem to do the same thing, except I can access more than just strings using EL.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not a matter of one over the other. You obviously have a JavaBean as a scoped variable named contactData. Whether you use JSP actions (like <jsp:getProperty>) or EL expressions (like ${contactData}) to reference the JavaBean, it's still a JavaBean. How you reference it doesn't change anything about the bean itself.

And you can use whichever mechanism makes the most sense within the context of its usage (though I almost always use the EL nowadays).

What you cannot do, as you discovered, is mix them up (trying to use a JSP action within an EL expression) as in your fist exmaple.
[ October 07, 2004: Message edited by: Bear Bibeault ]
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!