Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1093997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:54:35+00:00 2026-05-16T23:54:35+00:00

I was following a tutorial today that had me scratching my head for an

  • 0

I was following a tutorial today that had me scratching my head for an hour. Consider:

public class MyClass {
    public int getTotal() {
        amount = 100;
        return amount;
    }
}

and an excerpt from a JSP:

<p>Total: ${objectOfTypeMyClass.total}</p> //object instantiated elsewhere

Nowhere in the code was an instance variable named “total” ever declared or used. The only reference to the word “total” in the whole project (other than in the JSP) was the method getTotal().

So after some desperate last-ditch experimentation, it appears that Expression Language evaluates ${someObject.var} as “call the getVar() method of the someObject object.

I worked with this long tutorial for over a week thinking that ${someObject.var} was saying “directly fetch the saved instance variable “var” from someObject.

Did I have it wrong the whole time and is my observation correct that in order to reference any instance variable using EL, you have to provide a corresponding getter method named getVarname() where “Varname” is the name of the instance variable?

Also, EL seems to be case-insensitive in this regard. In my example above, “total” in ${objectOfTypeMyClass.total} is all lowercase where the method getTotal() has a capital “T”.

And while we’re at it, why don’t we need to instantiate the variable “total”? I guess EL isn’t actually referencing an instance variable…just a getter method?

What gives?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:54:36+00:00Added an answer on May 16, 2026 at 11:54 pm

    Did I have it wrong the whole time and is my observation correct that in order to reference any instance variable using EL, you have to provide a corresponding getter method named getVarname() where "Varname" is the name of the instance variable?

    That’s correct. EL adheres the JavaBeans specification as described in the EL specification.

    Also, EL seems to be case-insensitive in this regard. In my example above, "total" in ${objectOfTypeMyClass.total} is all lowercase where the method getTotal() has a capital "T".

    No, it’s certainly not case insensitive. It’s specified behaviour. ${bean.Total} would not have worked.

    And while we’re at it, why don’t we need to instantiate the variable "total"? I guess EL isn’t actually referencing an instance variable…just a getter method?

    It’s because it’s supposed to adhere the Javabean specification.

    All with all, read the both specifications and everything will be clear 🙂

    See also:

    • What are the advantages of Javabeans?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am following tutorial mentioned - http://code.google.com/p/snakeyaml/wiki/Documentation#Tutorial My code looks like public class Utilities
I'm following tutorial, installed RanvenDB embeeded and write: public static IDocumentStore archives = new
Following this tutorial and running into trouble. [TestMethod] [ExpectedException(typeof(Exception))] public void VerifyPropertyNameMethod_NonExistentPropertyString_ThrowsException() { var
The following is a great tutorial about using the Language Class. But I think
I'm fairly new to Grails and today was following a tutorial on spicing up
I'm trying the following tutorial: http://henrik.nyh.se/2007/03/ruby-wordwrap-method It has a block that needs to be
I am following the following tutorial ( http://www.highoncoding.com/Articles/642_Creating_a_Stock_Widget_in_ASP_NET_MVC_Application.aspx ) on using ajax to render
I am doing the following tutorial http://msdn.microsoft.com/en-us/library/ms731835%28v=vs.100%29.aspx and the program is working perfectly fine.
I'm using the following tutorial http://developer.android.com/resources/tutorials/views/hello-mapview.html in order to create a map view and
I have created a listview using following tutorial link http://www.ezzylearning.com/tutorial.aspx?tid=1763429 Outcome of this is,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.