*
The moose likes Struts and the fly likes Jsp refering to itself Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Jsp refering to itself" Watch "Jsp refering to itself" New topic
Author

Jsp refering to itself

namrata suri
Ranch Hand

Joined: Oct 22, 2009
Posts: 31
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

Joined: Sep 29, 2008
Posts: 12617

Moving to Struts.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 29, 2009
Posts: 145
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
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
Proper way (although mixing jsp with scriptlet java is not recommended):

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jsp refering to itself
 
Similar Threads
Struts 1.3.8 problem html:form
Validation messages not displaying in the alert box?
Problem in using Enumeration
Struts tags not working: html tag & bean tag
Struts: Can we have a html:text tag without a html:form tag outside it.