Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts Exception Handling in Struts.
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Clark
Exception Handling in Struts.
3 Answer(s)      3 years and 11 months ago
Posted in : Struts


How you can do Exception Handling in Struts ?


Advertisement
View Answers

November 19, 2010 at 12:44 PM


Hi friends,

In sruts you can handle the exception in two ways.

1 : Declarative Exception Handling: You can defined in struts-config.xml file. Ands if the exception occurs then controls will automatically passed to the appropriate errorpage.

  key="database.error.duplicate"

  path="/UserExists.jsp"

  type="mybank.account.DuplicateUserException"/>

Where

Key : The key defines the key present in MessageResource.properties file to describe the exception.
Type : The class of the exception occurred.
path : The page where the controls is to be followed is case excepation eccured.
Handler : The exception handler which will be called before passing the controlto the specified in patt attributes.

2 : Programmatic Exception Handling:
In this approach the exceptions are caught using normal java language try/catch block and instead of showing the exception some meaningful messages are displayed. In this approach the flow of control is also maintained by the programs. The main drawback of the approach is the developer has to write the code for the flow of the application.



November 19, 2010 at 1:07 PM


Hi friends,

In sruts you can handle the exception in to three ways

1 : Declarative Exception Handling:
You can defined in struts-config.xml file. Ands if the exception occurs then controls will automatically passed to the appropriate errorpage.

<exception

      key="database.error.duplicate"

      path="/UserExists.jsp"

      type="mybank.account.DuplicateUserException"/>

Where Key : The key defines the key present in MessageResource.properties file to describe the exception.
Type : The class of the exception occurred.
path : The page where the controls is to be followed is case excepation eccured.
Handler : The exception handler which will be called before passing the controlto the specified in patt attributes.

2 : Programmatic Exception Handling:
In this approach the exceptions are caught using normal java language try/catch block and instead of showing the exception some meaningful messages are displayed. In this approach the flow of control is also maintained by the programs. The main drawback of the approach is the developer has to write the code for the flow of the application.

Thanks.



May 12, 2011 at 11:53 PM


I think addFieldError(fiedName,Error Message);

is the right and well user friendly way to handle the exception. Just right addFieldError() in catch{ } and return "input"; from there .



Related Tutorials/Questions & Answers:
Exception Handling in Struts.
Exception Handling in Struts.  How you can do Exception Handling in Struts
Struts Exception Handling
Struts Exception Handling  Hi I want to display an user defined error message in my JSP by setting it in Struts 1.x custom handler class when some exception occurs. For example, I have 2 classes, Category and Product
Advertisements
Exception handling through Struts - Struts
Exception handling through Struts  I am using eclipse 3.2 and developing project in struts. I want to do error handling through struts. I have used.../ErrorPage.jsp and I have also made global-exception entry into my struts.xml file
exception handling
exception handling  explain about exception handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  could you please tell me detail the concept of exception handling
exception handling
exception handling   Give the exception hierarchy of Java.   Please visit the following links: http://www.roseindia.net/java/java-exception/exception-java.shtml http://www.roseindia.net/java/exceptions/exception
exception handling
exception handling  What is an exception and what are the advantages of exception handling mechanism.   Java Exception Exception are the runtime errors. Advantages: 1)Exception provides the means to separate
Exception handling
Exception handling  how to resolve file not found error exception
Exception Handling
Exception Handling  create an exception class, which thros an exception if operand is non-numeric in claculating modules. ( Use command line arguments
exception handling
exception handling  can you explain how to handle the exception in java with picture representation
Exception handling
Exception handling  exception are occur at run time but when we connect to the database errors will come at compile time why
Exception Handling
Exception Handling  wrtie a java program to enable the user to handle any change of divide by zero exception.   Please visit the following link: http://www.roseindia.net/java/exceptions/how-to-throw-exceptions.shtml
exception handling
exception handling  a program to accept only three integer values as command line arguments. Print the values entered by the user. Handle ArrayIndexOutOfBoundsException and NumberFormatException by providing the applied messages
exception Handling
exception Handling  write a program in Java to display the names and roll numbrs of students. Initialize respective array variables for 10 students. Handle ArrayIndexOutOfBoundsException, so that any such problem doesn't cause
Exception Handling
Exception Handling  Hi, I really appreciate the help I have gotten,I... for the student. Create an Exception class named GradeException that contains.... In the application, throw a Grade Exception if the user does not enter a valid letter
Exception Handling
Exception Handling  Hi, I really appreciate the help I have gotten,I... for the student. Create an Exception class named GradeException that contains.... In the application, throw a Grade Exception if the user does not enter a valid letter
exception handling in php - PHP
exception handling in php  i need few examples on exception handling in php
Java exception handling
Java exception handling  what are the constraints imposed by overriding on exception handling
exception handling mechanism
exception handling mechanism  Explain Java's exception handling mechanism in detail.   Please visit the following links: http.../exceptions/catching-and-handling-exceptions.shtml
Try and catch in Exception Handling.
Try and catch in Exception Handling.  How can we use try and catch block in exception handling?   Here is an example of Exception handling.... Then to perform exception handling, we have used try and catch block where we have
Exception Handling in java
Exception Handling in java  what is advantage to catch smaller exception first and then normal exception. I mean we normally catch SQLException first and then Exception.   Hi, The exceptions should be from
Advertisements
 

 

 

DMCA.com