wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes using EL to access java Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "using EL to access java Beans" Watch "using EL to access java Beans" New topic
Author

using EL to access java Beans

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

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




OCPJP 6.0 93%
OCPJWCD 5.0 98%
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60781
    
  65

Well, that tells you that there is something wrong with the syntax of your EL expression.

Check your syntax against the specification.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stoian Azarov
Ranch Hand

Joined: Jun 01, 2011
Posts: 113
${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

Joined: Jan 10, 2002
Posts: 60781
    
  65

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

Joined: May 18, 2010
Posts: 634

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

Joined: Jun 01, 2011
Posts: 113
@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
Bartender

Joined: Apr 07, 2010
Posts: 1632
    
  23

did you see my answer on your question in this thread?

Regards,
Frits
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60781
    
  65

"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

Joined: May 18, 2010
Posts: 634

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
 
subject: using EL to access java Beans
 
Similar Threads
Struts2 - execAndWait Interceptor
value for the useBean class attribute Invalid Problem
request time expression
Need help in learning struts
Unable to assign value to Bean property using jsp expression