File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using EL to access java Beans

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • 0
  • 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



 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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.
 
Stoian Azarov
Ranch Hand
Posts: 113
  • 0
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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
Chrome Eclipse IDE Java
  • 0
  • 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
  • 0
  • 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.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2167
57
Android Chrome Eclipse IDE
  • 0
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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
Chrome Eclipse IDE Java
  • 0
  • 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 agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic