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

error pages

 
Harshana Dias
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

I have declare a error page in DD as,


and i throw a Exception in my index.jsp ( <% throw new Exception(); %>) which catch from my_error.jsp

But again i throw the same Exception in index_new.jsp (make isErrorPage="true" too) but then i add a error page directive for my_error_new.jsp which is a new error page. but still it shows me my_error.jsp.

Why is it? should be display the my_error_new.jsp know?

Thank You.

 
Andriy Pererva
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not throw from scriptlets any checked exceptions, except ServletException or IOException which are declared in servlet's service() method.
If your need to throw from a JSP page some sort of business exception, you should wrap it in ServletException.
 
Harshana Dias
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andriy Pererva wrote:You should not throw from scriptlets any checked exceptions, except ServletException or IOException which are declared in servlet's service() method.
If your need to throw from a JSP page some sort of business exception, you should wrap it in ServletException.


Hey,

But i throw the Exception object from JSP (super class of any exception) and shows the error page as define in DD.

my problem is why cant be it done when im not using DD for error pages.


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65340
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't put it in the deployment descriptor, how on earth is it supposed to know about it? It can't read your mind.
 
Harshana Dias
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:If you don't put it in the deployment descriptor, how on earth is it supposed to know about it? It can't read your mind.


Hey Bear...

i mean we can either declare error pages on DD or directly in the JSP page as set page attribute isErrorpage="true"

so my question was when i throw Exception from my JSP and it was successfully catch by error page declare in DD.
But when i throw the same Exception from a another JSP and declare a error page that would be called if an error occuerd (in that JSPs page directive not in DD) that wont work..

We do not need DD to declare error pages if we use that page directive relevant attributes in both error generating page and error page right?

thats why i ask why its not working if i dont use DD for define error page
 
Alex Pustovit
Greenhorn
Posts: 10
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

in accordance with spec, even if some page defined in DD as error-page, a request should be redirected to the page defined in page directive.

So if you set <%@page errorPage="my_error_new.jsp"%> in you index_new.jsp it should be used.

Probably there is some wrong processing on server side when you throw new Exception object (as in your example). For real exceptions, for example division by zero case, correct page is shown.
 
Krishna Srinivasan
Ranch Hand
Posts: 1876
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to specify the new error page in DD
 
Alex Pustovit
Greenhorn
Posts: 10
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can specify new error page in DD. But you can overload page defined in DD using errrorPageattribute of page directive.
See JSP spec
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic