I have a basic question in struts why do we need to have <global-forwards>and <global-exceptions> in struts-config.xml. If we can achieve the same things with <action-mappings> itself.
I have a basic question in struts why do we need to have <global-forwards>
Share
<global-forwards>Consider you are validating the username password for different urls like
update.doinsert.dodelete.doIf it is a valid user, you need to proceed the necessary action. If not, you need to forward to the login page. Without a global forward, you must add a
loginform mapping form to every action:Instead of repeating the
<forward name="failure" path="/login.jsp"/>you can declare this in<global-forwards>like belowNow you can remove the
<forward name="failure" path="/login.jsp"/>in the action mappings.<global-exceptions>When you receive
java.Ioexception, instead of handling manually for each you can declare globally as below.I hope this clarifies your problem.