Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between type and forward???

 
subho saha
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to struts. Can somebody explain to me the difference between forward and type attributes of action element in struts-config.xml.
In books it is written type is used when we want to use an action and forward when we donot want an action to happen.But i want to know when should i use type and when forward in building a project..They seem to do the same job.What is the actual difference.

I am confused.
[ December 18, 2005: Message edited by: subho saha ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My view of this is that in almost every case, you will use Type instead of Forward. Using Type causes struts to call your action before forwarding to a JSP. In a real application, there is almost always some processing you want to do before displaying a JSP.

About the only thing I use the forward option for is when I have a simple jsp that requires no setup to display, but I don't really want the user to see xyz.jsp as the url on the browser. So, I set up an xyz action that forwards to xyz.jsp. That way the user sees xyz.do as the url on the browser.
[ December 18, 2005: Message edited by: Merrill Higginson ]
 
pax smith
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forward simply transfer the control to another JSP without having action class between them

Type refres to a action class that will be executed before JSP executes. It performs all the work perior to JSP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic