JSP EL and explicit error messages

M

massdriver

Hi,

I sometimes mistype object and property names in JSP EL expressions,
and find that no error is generated. It just doesn't evaluate the
expression.

For example, for an object named foo with a property of name, this
would throw an error:

<%= foo.getNAme() %>

where this won't:

${foo.nAme}

Is there any way to make it produce explicit errors in a case like this?
 
J

John C. Bollinger

massdriver said:
Hi,

I sometimes mistype object and property names in JSP EL expressions,
and find that no error is generated. It just doesn't evaluate the
expression.

For example, for an object named foo with a property of name, this
would throw an error:

<%= foo.getNAme() %>

where this won't:

${foo.nAme}

Is there any way to make it produce explicit errors in a case like this?

You're comparing apples and oranges.

Scriptlets are included directly in Java code at translation time, and
typos then cause the page compilation to fail. The container has no
alternative but to signal an error, which it generally does with HTTP
response code 500.

EL expressions, on the other hand, are evaluated at runtime by an
ExpressionEvaluator instance or by an Expression instance obtained from
an ExpressionEvaluator. Inability of either of these objects to
evaluate an expression should cause an exception to be thrown, but it is
possible for the page implementation to catch it, which may be your
problem. I don't see anything in the JSP 2.0 spec that says either way
whether a page compiler may provide default handling for such exceptions
inside the page -- though I think that would be odd -- but you may
have done it yourself in scriptlet code.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top