Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
  • Carey Brown
  • salvin francis
  • Piet Souris

Servlets-4a - using supplied files without modification?

Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just worked out how to solve a problem I was having using EL to print attributes of a VideoData object in the JSP with ${videoData.title}, but it involved modifying the supplied - is this allowed, or do I need to find some other way round the problem?  The instructions for this assignment say I "can use these files without modification", but do I have to?

A little context: I was getting a blank page and "javax.el.PropertyNotFoundException: Property 'title' not readable on type" in localhost.[today's date].log.   The best I could do was print out the output of the object's toString() method, but any attempt to access its properties failed.  I added the example Employee class and tried accessing its properties, and that worked fine, so I could then see that the public access modifier was the difference, and once I made VideoData public, it also worked as expected.

Also, I haven't got as far as working with the booleans dvd and vhs, but I noticed that their accessor methods are called inDVD() and inVHS(), shouldn't they be isDVD() and isVHS() in order to work with ${videoData.dvd} and ${videoData.vhs}?  So I need to know if I'm able to change these myself or if I have to find another way around it.
Posts: 3036
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, sorry about that. The original assignments had inVHS() and inDVD(). I vaguely remember that wasn't simply a typo, but I don't really remember the details. In any case, EL works with classes that strictly follow the JavaBean specification -- and that means naming accessors with "get", except for booleans where "is" is preferred. I remember updating the sample files, but it looks like either I'm wrong or that update got reverted at some point. Here's the you should be using:

Feel free to make other changes if the sample files aren't working right for you. Just give me a heads up, so I can correct them online if need be.
Every plan is a little cooler if you have a blimp. And a tiny ad.
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic