Deepaks Deshpande wrote:
Am I getting this exception because i am trying to access the same resource (add_customer.jsp) using different action paths /AddCustomerPage & /AddCustomer in the <action-mappings/>?
I am trying to redirect to the add_customer.jsp from my index.jsp page the code for which is as follows:
hai,I am not sure of my answer ,but i hope the following..
root cause is it is unable to load "ForwardAction" ,so please check whether you have added
" struts-extras-(version).jar" in CLASSPATH? because ForwardAction is built-in Action class and the super class of this class is "org.apache.struts.action.Action" class .and more over the Forward action class is available in "org.apache.struts.actions' package inturn this pachkage is available in
struts-extras-(version).jar .so please check this.
one more thing.. you stated:
I am trying to redirect to the add_customer.jsp from my index.jsp page
Generally speaking iit is a bad idea tp place within your
jsp pages any direct links to other JSP pages.For one reasong it is not good design decision;the struts-config.xml which is the part of the Controller ,should contain the entire flow of your application.
In Model-View-Controller architecture ,it is the role of the Controller to select the next View.The Controller consits of struts configuration ,theActionServlet,and the actions.Tf you add a link directly to another jsp,,you are violating MVC 2 principles.. where one resource should not communicate with other resouce directly but only should by means of Controller (ActionServlet if struts 1.x - and FilterDispatcher if struts 2.x).and more over struts framework strictly follows MVC2 principles.
for this you need to use ForwardAction class(built-in).
The ForwardAction acts as bridge from currect View(JSp) and teh pages it link to.It uses RequestDispatcher to forward to a specified webresource.It allows you to link to a action insted of directly to jsp.Later,if you need you can theActionMapping in the struts configuration to to a custom one that you write instead of using ForwardAction that struts provide.
To use ForwardAction:
1)use the html:link tag with the action attribut ,add alink to the jsp page that points to the action.
2)Create an action mapping in the struts in the struts configuration file that uses the ForwardAction with the parameter attribute to specify the Jsp path...