Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3284580
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:10:14+00:00 2026-05-17T20:10:14+00:00

This may be too ambiguous of a question, but I’m looking for some help

  • 0

This may be too ambiguous of a question, but I’m looking for some help or best practices on handling exceptions in a JavaServer Faces application.

Right now, whenever I catch an exception, I log it and then throw another exception that I created, say MyCustomException. This custom exception takes the Throwable object that was caught and emails the stack trace to me so that I know an exception has occurred. For now, this seems to work for me as far as being notified when an exception occurs.

However, the trouble that I’m having is how to present the user with a pretty error page that lets them know that something went wrong and that I have been notified of the error. Doing some searching, I’ve come across several articles that show how to redirect a user to another page using something similar to the following:

FacesContext context = FacesContext.getCurrentInstance();
ExternalContext extContext = context.getExternalContext();

String url = extContext.encodeActionURL(extContext.getRequestContextPath() +
    "/messages.faces");

extContext.redirect(url);

But this seems to be quite a bit to basically copy and paste for each caught exception, which doesn’t exactly follow the DRY principle. In the end, I think what I would like to do is have an email sent to me whenever an exception occurs and then be able to send a message to a generic error page that then displays the message to the user.

Any ideas or best practices that I should follow? Thank you in advance for any advice you can give! I’m stumped.

Note: If it helps, I’m using JSF 2.0 and Facelets.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:10:14+00:00Added an answer on May 17, 2026 at 8:10 pm

    This urls could be useful for you:

    http://weblogs.java.net/blog/edburns/archive/2009/09/03/dealing-gracefully-viewexpiredexception-jsf2

    http://andyschwartz.wordpress.com/2009/07/31/whats-new-in-jsf-2/

    http://download.oracle.com/docs/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/api/javax/faces/context/ExceptionHandler.html

    Basically you must use new feature in JSF2.0, ExceptionHandler. This is a central point for handling unexpected exception.
    You could indicate which page use for each exception type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question may be too product specifc but I'd like to know if anyone
This may be too opinionated, but what I'm trying to understand why some companies
i'm a long-time newbie to c#, and this question may be too obvious, so
Alright, I am going to state up front that this question may be too
This may seem like a daft question, but i was wondering about how to
this may sound too simple, but I'm missing something. I need to write a
This may be too simple.Please help. List<Line> listLines = new List<Line>(); foreach (Point p
This may be a no-brainer for the WPF cognoscenti, but I'd like to know
This may seem like a programming 101 question and I had thought I knew
This may be simple one, but 5 mins of Googling didn't give me the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.