Struts mapping recap
Here is a sample stuts action mapping:-
<form-beans>
<form-bean name="TestForm" type="com.test.form.TestForm">
</form-bean>
<action-mappings>
<action path="/Test" parameter="action" type="com.test.action.TestAction" scope="request" validate="false" name="TestForm">
<forward name="list" path="/web/jsp/test.jsp" redirect="false">
</forward>
</action>
The name parameter is what tells what is the form.
In the above the parameter action is what defines where the execution of the struts dispatch action will go to.
For example /Test?list will go a method called list in the Test Dispatch action.
There is only one forward above with the same name list, so mapping.findforward("list"), will forward to "
If it were to be redirect=true, the conatiner would forward the "
In short instead of just a forward to test.jsp , it forwards to test.jsp and then forces the browser to submit test.jsp again.
Internally this is done using two diffetent serlet api methods.
The forward is done using the requestdispatcher forward method
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/RequestDispatcher.html#forward
The redirect is done using the sendRedirect method of the http response object.
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletResponse.html#sendRedirect
Needless to say whatever was there in the first request scope will be lost.One way to not loose pervious request data is the use of hidden variables back and forth but this can be very cumbersome.
0 Comments:
Post a Comment
<< Home