Redirection In the Case of Null Pointer Exception in Struts

Hi,
       I want to address the below Scenario.
       I am using Struts and a null pointer exception is occuring in my action class? In this case instead of showing the server error page, I want to redirect to my customized Error Page? How do i achieve this in Struts
java2009Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StealthyDevCommented:
You need to configure in web.ini

find the relevant posting here:

http://www.roseindia.net/struts/struts2/actions/struts-2-redirect-action.shtml
0
sreekanthbhargavCommented:
U can use either Global Exception Handling/ Exception handling for Action. Depends on the requirement u can use global or action specific here i can give... action specific exception..

you need to handle an exception in a specific way for a certain action you can use the exception-mapping node within the action node.


   <action name="actionspecificexception" class="org.apache.struts.register.action.Register" method="throwSecurityException">
     <exception-mapping exception="org.apache.struts.register.exceptions.SecurityBreachException"
          result="login" />
      <result>/register.jsp</result>
      <result name="login">/login.jsp</result>
   </action>

The above action node from the example application's struts.xml file specifies that if method throwSecurityException throws an uncaught exception of type SecurityBreachException the Struts 2 framework should return a result of login. The login result will cause the user's browser to be redirected to login.jsp.

You can see that an action-specific exception mapping will take precedence if the same exception is also mapped globally

0
sreekanthbhargavCommented:
Here above i have given an example.. Base on ur exception type you can give the results page...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.