Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pageContext.exception is not executing

 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
start.jsp


errorPage.jsp


web.xml


when i run start.jsp output is
pageContext Error is !!!java.lang.ArithmeticException: / by zero
Error is !!!java.lang.ArithmeticException: / by zero

Here is my problem
Now if i remove <%@ page errorPage="errorPage.jsp" %> line from start.jsp page the output is
pageContext Error is !!!
Error is !!!java.lang.ArithmeticException: / by zero

i.e ${pageContext.exception} is not executed.

why it is so?

Thanks
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its working fine in my computer.
Both error messages are same.
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using Tomcat 5.0
Operation system is windows 2000 professional.
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also using Tomcat 5.5.
I think its your browser problem.
Use Mozilla Firefox instead of Internet Explorer.
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using Mozilla Firefox
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i also tried Internet Explorer but it is not displaying.
 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a DD error-page elemnt as well directing the container towards the error-page? Otherwise how does it go to the error page when you remove <%@ page errorPage="errorPage.jsp" %> ...?
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have already configured errorpage in DD
 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm gettin' the same thin'....lemme see if I can figure it out
 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok...here's the explanation...not satisfactory...but at least you know what's happening

Irrespective of whether you use the page directive <%@ page errorPage="errorPage.jsp" %> in test.jsp or not, important thing is that you have included the page directive <%@ page isErrorPage="true" %> in errorPage.jsp which is a requirement in order to get the JSP Implicit object exception...

Now, when you use the page directive <%@ page errorPage="errorPage.jsp" %> in test.jsp, the container returns the Exception associated with the errorPage.jsp since ${pageContext.exception} is actually pageContext.getException() called from errorPage.jsp...but when you don't use the directive in test.jsp, the container does not associate the exception with errorPage.jsp....I dunno why exactly this happens but I did fing the difference in method arguments(in the former case "errorPage.jsp" is passed but in the latter case it's null) passed when the container gets the pageContext implicit object....you can see it for yourself by checking the generated servlet code for test.jsp in both cases...Somethin's happenin'....not exactly sure because these methods are way too complex...BUT yeah I guess the reason why you're getting the JSP implicit object "exception" is exactly as explained above and it's mentioned in HFSJ as well(hand-written note Page 461)

Hope that helps to some extent
[ December 08, 2006: Message edited by: Sayak Banerjee ]
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sayak what are saying.
It works fine with or without <%@ page errorPage="errorPage.jsp" %>.
 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It didn't in my case....I got the exact same output as Gowher had explained earlier...I'm using Tomcat 5.0.28/Win XP....tried in Mozilla Firefox as well as Intenet Explorer....thats the reason I went for the generated servlet files for test.jsp in both cases and found the subtle differnece in them (which I pointed out)...I'm not sure if you have a better explanation for this but this is precisely what's happenin'
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic