• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

error pages

 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Sheriff
Posts: 67756
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
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: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 10
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic