Hi,
The following is the structure of the code I am working on
index.jsp - first page
SelectedItemActionForm - a form class for the index.jsp
SelectedItemAction - action class for index.jsp
I have made entries in struts-config.xml file
<forward name="success" path="/path1.jsp">
<foward name="failure" path="/path2.jsp">
The code is working fine for path1 since that is just a normal jsp file that is printing a message.
Now, path2.jsp ... the code is as follows
Now, the error I am getting is
cannot retrieve mapping for action /path2
Since I am not using beans here, do I have to make an entry in action mappings in struts-config.xml and what should it be since no beans are allowed here.
You're using a JSP as the "action" attribute for the form. Besides that in general you don't want to submit to a JSP, the "action" attribute is expected to be just that--an action.
As i remember and as David said, you are suppose to use a real Action(servlet) in case of Struts 1 and do validation and respectively do return (mapping.findForward("failure")); or success depending on what you want. The point of the framework is MVC, so you would want to use the controller to dispatch around relative to validation or something else. There's a struts Login example here that shows the proper way to use the framework basicly: http://www.vaannila.com/struts/struts-example/struts-login-page-example-1.html
namrata suri
Ranch Hand
Joined: Oct 22, 2009
Posts: 31
posted
0
Thank you for the replies. I changed my code now. I have another doubt though.
I am using the jsp to take a value and am passing it to another jsp.
<%@ page import="java.util.*" %>
Now depending on the loop, some n values are being submitted in this form. I am catching all those in this code
Problem is the parameters thing is not getting all the values submitted in the previous form. Its just taking the first 2 values.
Tudor Raneti
Ranch Hand
Joined: Nov 29, 2009
Posts: 145
posted
0
Proper way (although mixing jsp with scriptlet java is not recommended):
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.