Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jsp refering to itself

 
namrata suri
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thank You.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Struts.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Proper way (although mixing jsp with scriptlet java is not recommended):

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic