• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt property of bean

 
Anais Aponte
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

In the page 447 of the book HFSJ in the last key points and gotchas with <c:set> says: ...But be careful, because the EL expression by itself will NOT cause an exception if the property doesn't exist. So even though: ${fooBean.notAProperty} won't cause an exception by itself (it just return null)..."
but I tested this:
code Bean

code servlet:

code viewCap9.jsp


But the Container throws me an exception and is the following one:

excepci�n

excepci�n

org.apache.jasper.JasperException: Exception in JSP: /viewCap9.jsp:18

15: </table>
16:
17: <h3>Datos de la Persona</h3>
18: Nombre: ${persona.last} <br>
19:
20: </body>
21: </html>


causa raiz

javax.servlet.jsp.el.ELException: Unable to find a value for "last" in object of class "foo.Person" using operator "."
org.apache.commons.el.Logger.logError(Logger.java:481)
org.apache.commons.el.Logger.logError(Logger.java:498)
org.apache.commons.el.Logger.logError(Logger.java:611)
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
should it be Nombre: ${persona.name} ? The is no last property in the person object
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Concerning accessing bean properties, here is what the spec tells us :
(value-a is a bean, value-b is the property)

If value-b is a readable property of value-a, as per the JavaBeans specification:
� If getter throws an exception: error
� Otherwise: return result of getter call
Otherwise: error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic