File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Problem with Forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with Forward" Watch "Problem with Forward" New topic

Problem with Forward

maverick Mohan

Joined: Jun 11, 2008
Posts: 6

I have two action classes. I am trying to forward to Action2 from Action1 using struts_config.xml and action-mapping.

My problem is.

I get input in JSP1 and depending on the input (age) I am using Action1 to forward to corresponding Action2. I have worked with struts couple of years back so I need help understanding the flow of mechanism here.

I want to display data in JSP2 using Action2 but whenever I call Action2, I got error message from ActionForm2 validate method. I am getting data from DB, so I know the ActionForm error should not be there. I also put SOP statements and I figured out, That after I forward from Action1- I get JSP2 with ActionForm validate error. Action2 is not even called.

I want to call Action2 before JSP2 loads, because I want to show data for manupulation by users. Also, Action2 works if I insert new data and press submit button.

Please tell me why, Action1 forward is fetching JSP2 with ActionForm2 validate error message.

Thanks, Mohan
Anuj Singh
Ranch Hand

Joined: May 04, 2007
Posts: 47
Hi Mohan,
Well,the forward attribute of Action mapping element of struts-config is used is used if you do NOT want an action to service the request.So basically the forward attribute is used to specify the context relative path of JSP or SERVLET resource that process the request.
Remember,Struts is based on MVC,so do NOT try to mix up the presentation and the controller parts.The struts-config.xml is the main configuration file for Struts. Its where all the struts Actions are defined and what JSP pages are used to display them.


SJCP 1.5 with 93%.Preparing for WCD
I agree. Here's the link:
subject: Problem with Forward
jQuery in Action, 3rd edition