Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlets-4a - using supplied files without modification?  RSS feed

 
Greenhorn
Posts: 18
1
  • Mark post as helpful
  • send pies
  • 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 VideoData.java - 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 com.javaranch.drive.videos.VideoData" 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.
 
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • 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 VideoData.java 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!