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

Problem with Forward

 
maverick Mohan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks
Anuj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic