• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

using EL to access java Beans

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am usin EL to access beans but i get blank browser window

and on using the following EL

${developer.["builds"].build_number} in the jsp

i get the following error:

org.apache.el.parser.ParseException: Encountered " "[" "[

jsp



Bean-Developer


Bean--Builds



 
Sheriff
Posts: 67403
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that tells you that there is something wrong with the syntax of your EL expression.

Check your syntax against the specification.
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${developer["builds"].build_number}
not

${developer.["builds"].build_number}

if developer is set properly in one of the 4 scopes, of course.
 
Bear Bibeault
Sheriff
Posts: 67403
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, now that Stoian Azarov has blurted out the answer and robbed you of the learning opportunity of looking up the EL syntax, you know what the syntax error was. You use either of the dot (.) or the bracket ([]) operators, but never both at the same time on a single term.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
even this following EL syntax doesnot seems to work

${developer["builds"].build_number}

I get nothing in the output corresponding to this EL
 
Stoian Azarov
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear Bibeault - sorry for intervening, I do support the idea that the best way to learn is by thinking and searching for explanation by. I will be more careful the next time.

@mohitkumar gupta - the info you provide is a little sparse. what does that mean:

I get nothing in the output corresponding to this EL

- there is no output
- the whole EL expression is printed(plain text)
- nothing strange in the console

Just a fast thought - the first element of you EL expression should be either implicit object or scope attribute.
 
Creator of Enthuware JWS+ V6
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you see my answer on your question in this thread?

Regards,
Frits
 
Bear Bibeault
Sheriff
Posts: 67403
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Not working": does;t help. What is happening?

It's time to debug each step of the way.

By the way, if "builds" is static, there's not need to use the general (bracket) operator. Why aren't you just using ${developer.builds.build_number} ?
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is no output corresponding to EL:

${developer["builds"].build_number}

I have updated the jsp :




In head first servetls and jsp(2nd edition), chapter-8 scripltess jsp pg-372



1.if the expression has a variable followed by bracket[],the left hand varaible can be a Map,Bean ,List,Array
2.if the thing inside brackets is a string literal ,it can be a map key ,bean property or an index.

Here developer is a bean with builds as a property which itself is a bean with build_number property.

I just want to try different ways we can access beans using El that why i am using the general(bracket) operator.
 
I can't take it! You are too smart for me! Here is the tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic