• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Expression Language, Tomcat and JasperException

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody,

I'm wondering for couple of days how to resolve one problem in my JSP.
I don't know how to configure Tomcat to pass through:
${someBean.someField}
without exception, even if someField doesn't exist in someBean class.

Is it possible?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is not possible as that would be a violation of the JSP Specification. If the property does not exist on the bean, an exception will be raised.
 
Piotr Kiraga
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've assumed like You. But some time ago I've received such a post:

I don't know why ${!empty actionBean.result} would throw that exception. When I do that in my JSP, it just prints "false", even if my action bean doesn't have a result property, but I'm using Resin.
...cut...
If it's throwing an exception, I think that is a tomcat problem.



So, You suggest, that it's not true and this exception in my Tomcat is appropriate?

Some background:
I'm trying to use one JSP file for two classes/actions in Stripes MVC framework. When it's requested from first action there doesn't exist some property in other case it exists. In Struts it's easy to check by struts taglibs. Here (in Stripes) I have a little problem.
[ February 20, 2007: Message edited by: Piotr Kiraga ]
 
Piotr Kiraga
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
It is not possible as that would be a violation of the JSP Specification. If the property does not exist on the bean, an exception will be raised.



Otherwise. How to check safely (by EL) that bean exists, and furthermore, that it has a property.

Regards.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The relevant language from the JSP Specification, while terse, is crystal clear:

Otherwise (a JavaBeans object), coerce value-b to String

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.



So, no.

And that's to be expected. Bean properties are not dynamic. Each bean has its properties and they should be well-known and they do not change over the life of the bean.

For a construct with dynamic properties, you might want to investigate using a Map. This article discusses just that.
[ February 22, 2007: Message edited by: Bear Bibeault ]
 
Piotr Kiraga
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for Your reply.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic