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 8632151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:18:46+00:00 2026-06-12T09:18:46+00:00

I have the following web.xml <error-page> <error-code>500</error-code> <location>/WEB-INF/views/errorPages/500.jsp</location> </error-page> <error-page> <exception-type>java.lang.Exception</exception-type> <location>/WEB-INF/views/errorPages/error.jsp</location> </error-page> <error-page>

  • 0

I have the following

web.xml

<error-page>
    <error-code>500</error-code>
    <location>/WEB-INF/views/errorPages/500.jsp</location>
</error-page>

<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/WEB-INF/views/errorPages/error.jsp</location>
</error-page>

<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/WEB-INF/views/errorPages/500.jsp</location>
</error-page>

spring-context.xml

<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    <property name="exceptionMappings">
    <props>
        <prop key="java.lang.Exception">error</prop>
    </props>
    </property>
</bean>

<bean id="exceptionResolver"
    class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">

    <property name="exceptionMappings">
        <props>
            <prop key="com.company.server.exception.GenericException">GenericExceptionPage</prop>
            <prop key="java.lang.Exception">error</prop>
        </props>
    </property>

    <property name="defaultErrorView" value="defaulterror"></property>
</bean>

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix">
        <value>/WEB-INF/views/</value>
    </property>
    <property name="suffix">
        <value>.jsp</value>
    </property>
</bean> 

GenericException.java

public class GenericException extends RuntimeException
{
  private static final long serialVersionUID = 1L;

  private String customMsg;
  public String message;

  public String getCustomMsg()
  {
    return customMsg;
  }

  public void setCustomMsg(String customMsg)
  {
    this.customMsg = customMsg;
  }

  public GenericException(String customMsg)
  {
    this.customMsg = customMsg;
  }

  @Override
  public String getMessage()
  {
    return message;
  }

}

myController.java

@Controller
@RequestMapping(value = "/admin/store")
public class AdminController
{


 //bunch of restful drivin requestMappings


}

Question:
How do I get any and all internal server errors & exceptions to display the exception/error message to a single page?

  • 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-06-12T09:18:47+00:00Added an answer on June 12, 2026 at 9:18 am

    I would consider using the @ExceptionHandler annotation on a method in my controller. This annotation marks a method to be invoked by Spring when an Exception bubbles its way up past the controller.

    This way, when one of your @RequestMapping methods throws an Exception, then this method will be invoked and can return whatever error message you would like.

    public class BaseController {
        @ExceptionHandler(Throwable.class)
        public String handleException(Throwable t) {
            return "redirect:/errorPages/500.jsp";
        }
    
        @ExceptionHandler(Exception.class)
        public String handleException(Throwable t) {
            return "redirect:/errorPages/error.jsp";
        }
    }
    
    @Controller
    @RequestMapping(value = "/admin/store")
    public class AdminController extends BaseController
    {
        @RequestMapping(...)
        //Some method
    
        @RequestMapping(...)
        //Another method
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application web.xml with the following entry: <error-page> <error-code>404</error-code> <location>/system_files/error/p_notfound.jsp</location> </error-page> However,
I already have the following declared in my pages.xml : <exception> <http-error error-code=500 />
In my web.xml page I have the 404 error mapped to a jsp page
I have the following XML in my web.config <mySectionGroup> <sectionOneSection> <page path=~/123.aspx></page> <page path=~/456.aspx></page>
I have following web-fragment.xml in a jar file, under META-INF/ It seems I cannot
I have configured in following way that spring MVC app using Spring 3.1.1.RELEASE web.xml
In the web.xml of my web app I have configured the server as following:
I have the following Web page: link to page . If you go to
I Have following code with LINQ var q = (from web in DataContext.Webs select
In a web project using jsp, I have following requirement Upload a file (say

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.