I'm running Tomcat 6.0.18 on Linux.
I have a JSP that uses a bean like this:
<jsp:useBean id="helper"
type="com.example.SomeType"
scope="request"/>
The page references an attribute of helper
with the expression language like this:
<!-- This works properly, but could fail silently if the bean name is incorrect. -->
<div><p>Here's some stuff: ${helper.stuff}</div>
During some refactoring in which I missed an occurrence of the name helper
, I noticed that no error is raised if the name helper
is written incorrectly. Not on the screen, and not in my log files. Nothing is produced for the expression language snippet in the output:
<!-- Wrong name! "foo" should be "helper" but no error is observed (other than missing ouput)! -->
<div><p>Here's some stuff: ${foo.stuff}</div>
Now, an error is raised (my custom error page displays and I see an exception in my log file) if I use the following JSP syntax with an incorrect name for helper
:
<!-- Wrong name, but an error is raised. -->
<div><p>Here's some stuff: <jsp:getProperty name="foo" property="stuff"/></div>
In this case, the log records this entry:
SEVERE: requestURI: /some.jsp servletName: jsp statusCode: 500
org.apache.jasper.JasperException: Attempted a bean operation on a null object.
For completeness, the jsp:getProperty
syntax works properly when the bean name is correct:
<!-- Works properly, protects me from an incorrect name, but is more verbose than EL. -->
<div><p>Here's some stuff: <jsp:getProperty name="helper" property="stuff"/></div>
Why don't I see an error when I write ${foo.stuff}? Is there some configuration option that controls error reporting in such cases?