• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Marcus Green Notes , Question on c:set

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am reading Marcus Green notes for SCWCD as I am preparing for the exam.

I try to run sample code for <c:set> using target for Benas and Maps.Section 9.3

Here is the code



The JSP page is as follows





I am getting the following exception

javax.servlet.jsp.JspTagException: Invalid property in <set>: "MyField"
at org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(SetSupport.java:188)
at org.apache.jsp.demo_jsp._jspx_meth_c_set_1(demo_jsp.java:147)
at org.apache.jsp.demo_jsp._jspService(demo_jsp.java:91)

Could someone please tell me what is going wrong


Thanks
Archana
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marcus' notes are IMHO a little confusing in this example, and I can see why you made a mistake.

In the DemoBean class the instance variable "MyField" should IMHO follow the naming conventions and have a lowercase leading letter - myField.

The getter and setter methods should / will automatically capitalize the variable in the method name i.e. getMyField setMyField .

Then in the jsp the <c:set...> will refer to the instance variable by it's uncapitalized name:

<c:set target="${demo}" property="myField" value="guru" />

In your example you've capitalized the property to match the instance variable (which is wrongly named). However the set tag handler can't then capitalize this to identify the appropriate setter method.

e.g. it can't turn MyField in the getMyField but it can turn myField in to getMyField

Confused?

Rufus.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rufus, please check your private messages.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Field name MyField has nothing to do with a property name of Javabean. It could have been something completely different like this:



And even then the name of the property would be myField, because it is derived from getter method.

So basically the only change needed here is this:



("MyField" changed to "myField")
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic