Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using exception in EL

 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I have the following page...



When the above page is called from another page as an error page, I get the following output...

[output]
ArithmeticException.jsp
java.lang.ArithmeticException: / by zero
class java.lang.ArithmeticException
/ by zero
var e contains:
[/output]

You will see that the EL variable e was not assigned anything. But as I understand it ${pageContext.exception} is a bean, and should be assignable to a variable with <c:set>. I have used <c:set> to assign other beans to variables.

Why does this not work?

Thanks in advance!
John
 
sudipto shekhar
Ranch Hand
Posts: 826
Chrome Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by JohnWilliam Fitz:




But as I understand it ${pageContext.exception} is a bean, and should be assignable to a variable with <c:set>.



exception is the object that the container gives to a JSP that handles the exception. To be more precise it is an implicit object.

I don't think ${pageContext.exception} is a bean.
When using <c:set var="e" value="${pageContext.exception}" /> make sure that var should a scoped attribute and not a map or bean.
<c:set target="bean/map" value="notNull"> is used for beans or map.


 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be ok, but didn't you forget to declare the JSTL library ?

Look into the HTML source of the error page. If you see the c:set tag, it's time to have a cup of coffee
 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It should be ok, but didn't you forget to declare the JSTL library ?


DOH!!!

Makes me wonder, can I do a "global declaration" of the jstl library somehow? I'm CONSTANTLY forgetting to include it!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In web.xml, you could use a prelude to inclue automatically a file to every jsp files :

Web.xml:

taglibs.jspf


But for the moment, it may be better to remember to declare the prefix of JSTL tags wherever you use them.
 
sudipto shekhar
Ranch Hand
Posts: 826
Chrome Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Christophe Verre:
In web.xml, you could use a prelude to inclue automatically a file to every jsp files :

Web.xml:

taglibs.jspf



This is great. I do not know XML. So where do i find these JSP specific tags?
[ November 25, 2008: Message edited by: Sudipto Shekhar ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So where do i find these JSP specific tags?

In the JSP specification.
 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the JSP specification.


Along with pretty much everything else one might ask about JSP, I have learned.
 
Surajsingh Thakur
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Specs are really helpfull
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic