Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Errata on HF question?

 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys (I'm using the term 'guys' not in the gender way . I've already checked on the errata for this question but I couldn't find anything. Here's the question (which you can find on page 423 of HFJSP).

Given the following class:


Which will cause errors, assuming that an attribute named "mybean" of type MyBean can be found?

a) ${mybean.name}
b) ${mybean["name"]}
c) ${mybean.objects.a}
d) ${mybean["params"].a}
e) ${mybean.params["a"]}
f) ${mybean["objects"].a}

The book give as answers C and F, because objects in not a Map and a lookup will not be performed. However, I'm trying with Tomcat 5.4 and in any of the above cases I don't get an exception. However, if I add something like ${mybean["trallalla"]}, I get the following exception:

[list-start]
javax.servlet.ServletException: Unable to find a value for "trallala" in object of class "org.jemos.certs.vo.MyBean" using operator "[]"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:845)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:778)
org.apache.jsp.elFunction_jsp._jspService(org.apache.jsp.elFunction_jsp:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


[list-end]

This is the java class that I wrote:



and this is the JSP page:


Now, is it Tomcat too smart, so it doesn't produce an error even when it should, or is there an errata for this question?

Thanks for any help,
[ January 23, 2005: Message edited by: Marco Tedone ]
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found that the problem was due to Tomcat 5.5 and not to the HF. With Tomcat 5.0 the container throws an exception.

Marco
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic