Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Possible to be notified of bad EL syntax / unresolved variables?  RSS feed

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using Tomcat 6.0.26 (Java 1.6). Occasionally in our JSP pages, we have bad EL syntax like ...



Notice the front bracket ("["). Also, there are other times even when we do have the syntax correct, but a variable is undefined ...



Is it possible to get exceptions thrown when such errors occur? We spend a lot of time debugging things like this, whereas if we were to use scriptlets, we would get compile errors, but we begin to violate the separation of presentation and business logic paradigm.

Thanks for any thoughts, - Dave
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing Tomcat-specific here, so moved to the JSP forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, no.

In the first case, the malformed text will simply be translated as template text.

For the second case, the EL spec defines when exceptions will be thrown, and when the expression will simply result in the empty string. In a nutshell: undefined or null scoped variables result in an empty string, invalid properties or indexes result in an exception. So for the example: ${myVarr.property1} , if myVarr doesn't exist or is null, no problem; the empty string is emitted. If property1 doesn't exist on myVarr, exception.

A JSP-enabled IDE such as IntelliJ can help detect undefined variables such as the latter case, but cannot help with the first case because there's noting invalid about it.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Alvarado wrote:We spend a lot of time debugging things like this

Really? In terms of number of occurrences, or amount of time for a small number?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!