Using the Struts Logic Tags to Transfer Control


Sometimes you need to transfer control to another page inside the current application or to an arbitrary URI entirely outside the application. Two tags in the logic library are designed to enable you to do this.

The logic:forward Tag

The forward tag causes a transfer of control using a global ActionForward defined in the Struts configuration file. It takes a single attribute, name , which is the name of the forward. For example:

 <logic:forward name="badlogin"/> 

The logic:redirect Tag

On its surface, the redirect tag seems complicated until you realize that all the attributes are the same as their namesakes in the <html:link> tag. The only difference is that whereas the link tag comes into effect when the link is clicked, the redirect tag takes effect immediately. Refer to the documentation on the link tag for details. Here's an example of this tag:

 <logic:redirect href="http://www.cnn.com" paramId="userid" paramName="myUserId"/> 


Struts Kick Start
Struts Kick Start
ISBN: 0672324725
EAN: 2147483647
Year: 2002
Pages: 177

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net