logic:redirect

 < Day Day Up > 



<logic:redirect />

The <logic:redirect /> tag uses the HttpServletResponse.sendRedirect() method to redirect the current request to a resource identified by either the forward, href, or page attributes. The <logic:redirect /> tag has no body and supports 12 attributes, described in Table 18.5.

Table 18.5: <logic:redirect /> Tag Attributes

Attribute

Description

anchor

Used to append an HTML anchor to the end of a generated resource. (Optional)

forward

Identifies the name of a global forward element that will receive control of the forwarded request. (Optional)

href

Specifies the URL of the resource to forward the current request to. (Optional)

name

Identifies a scripting variable referencing a java.util.Map object whose collection of key/value pairs is used as HTTP request parameters augmenting the redirected request. (Optional)

property

Identifies a bean property of the bean named by the name attribute that contains a java.util.Map reference whose collection of key/value pairs is used as HTTP request parameters augmenting the redirected request. (Optional)

scope

Defines the scope of the bean specified by the name attribute. If the scope attribute is not specified, then the tag will search for the bean in the scopes, in the order of page, request, session, and application. (Optional)

transaction

If set to true, indicates that the current transaction control token should be included in the generated URL. The default value is false. (Optional)

page

Specifies a context-relative path to a resource that will receive control of the current request. You must prepend the named resource with the / character. (Optional)

paramId

Identifies the name of a request parameter that will be added to the generated URL. The corresponding value of this parameter is defined by the paramName attribute. (Optional)

paramName

Specifies a JSP scripting variable, containing a String reference, that represents the value for the request parameter named by the paramId attribute. (Optional)

paramProperty

Identifies a bean property of the bean named by the paramName attribute; the property will be used as the value of the parameter identified by the paramId attribute. (Optional)

paramScope

Specifies the scope of the bean specified by the paramName attribute. If the paramScope attribute is not specified, then the tag will search for the bean in the scopes, in the order of page, request, session, and application. (Optional)

An example of using the <logic:redirect /> tag is shown here:

 <logic:redirect name="login"   param paramName="company" /> 

In this example, we perform a redirect to the global forward login. This resource must be defined in the <global-forwards /> section of the struts-config.xml file. The <logic:redirect /> tag differs from the <logic:forward /> tag in that the <logic:redirect /> tag allows you to dynamically augment the request with parameters.



 < Day Day Up > 



Professional Jakarta Struts
Professional Jakarta Struts (Programmer to Programmer)
ISBN: 0764544373
EAN: 2147483647
Year: 2003
Pages: 183

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