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

Getting Java Map entries using JSTL

Ruben Matthews
Greenhorn

Joined: Jan 05, 2009
Posts: 26
Hello,

I am trying to read entries from a Java Map called 'fieldStates' in a JSP. This expression in the JSP:

${fieldStates.uniqueName.valid}

results in the error message: Property 'valid' not found on type controller.FieldState

FieldState is in the controller package and has a public boolean variable called 'valid'. And it is compiled and ready in the \WEB-INF\classes\controller directory.

Am I using the wrong syntax? I have tried some other things, like iterating over the map and printing the object references, but I can't seem to get to the properties.

I use Tomcat 6.0.18 and JSTL 1.1

Thanks



Ruben Matthews
Greenhorn

Joined: Jan 05, 2009
Posts: 26
I got it. The FieldState objects I use in my Map<String, FieldState> didn't have getter and setter methods. Apparently JSTL needs these to access properties of FieldState. It now works.
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
removed


“Everything should be as simple as it is, but not simpler.” Albert Einstein
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

good catch


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

Ruben Matthews wrote:I got it. The FieldState objects I use in my Map<String, FieldState> didn't have getter and setter methods. Apparently JSTL needs these to access properties of FieldState. It now works.

Exactly. The EL (not JSTL) operates on Beans. It will only find bean properties. No methods. No fields. Nothing except bean properties.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
This is true if you are using the standard EL implementation. The JBoss EL goes a bit further on that.

This is an interesting read: http://docs.jboss.org/seam/2.0.2.SP1/reference/en-US/html/elenhancements.html

Similar enhancements are requested on the JSP EL spec according to its issuetracker. We may see it back in future specifications.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

As this is the JSP forum, let's not muddy the waters with JBoss-proprietary extensions.
Ruben Matthews
Greenhorn

Joined: Jan 05, 2009
Posts: 26
Bear Bibeault wrote:
Ruben Matthews wrote:I got it. The FieldState objects I use in my Map<String, FieldState> didn't have getter and setter methods. Apparently JSTL needs these to access properties of FieldState. It now works.

Exactly. The EL (not JSTL) operates on Beans. It will only find bean properties. No methods. No fields. Nothing except bean properties.


Ah, yes, EL. Not JSTL.

It very often happens that I find the solution to an issue while I'm typing or have just typed a forum thread. It forces me to summarize the issue and consider everything I've tried and I often find new things to try while doing this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting Java Map entries using JSTL