• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP and custom Exception class

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to generate a custom error and then send it to the Error.jsp page but I am having a problem. Here is what I have done:
I have created a very basic exception class.
package lampoonslodge;
public class SessionException extends Exception {
public SessionException(){
super("Session or page has expired");
}
}
/************************************************************/
I then have a jsp with the following line of code-
if(true)
throw (new SessionException());
/**************************************************************/
In my web.xml file I have the following syntax
<error-page>
<exception-type>lampoonslodge.SessionException</exception-type>
<location>/Error.jsp</location>
</error-page>
/**************************************************************/
So why does it not work
When the code executes int the jsp it does display my error message but under a 500 error heading. It does not go to error page.
Could someone please help me with this one.
Thank you ver much david
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,
I m not sure abt
<error-page>
<exception-type>lampoonslodge.SessionException</exception-type>
<location>/Error.jsp</location>
</error-page>
but I think jsp provides better and easy option for above lines as
<%@ page errorPage="Error.jsp" %> this will appear in ur main jsp
and
<%@ page isErrorPage=true %> in Error.jsp
Hope this solves ur problem
Praful
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic