Preface

Comment

Declaration

Expression

Scriptlet

EL Expression

Directives

Attribute Directive

Include Directive

Page Directive

Tag Directive

Taglib Directive

Variable Directive

Standard Actions

<jsp:attribute>

<jsp:body>

<jsp:element>

<jsp:doBody>

<jsp:forward>

<jsp:getProperty>

<jsp:include>

<jsp:invoke>

<jsp:output>

<jsp:plugin>

<jsp:root>

<jsp:setProperty>

<jsp:text>

<jsp:useBean>

<jsp:forward>

Forwards a request to a web resource.

JSP Syntax

<jsp:forward page="{relativeURL | '${' Expression'}' | 	
   <%= expression %>}" { /> | > [<jsp:param name="parameterName" 
value="{parameterValue | '${' Expression '}' | <%= expression %>}" } 
/> ]+ </jsp:forward>}

XML Syntax

<jsp:forward page="{relativeURL | '${' Expression '}' | 	
   %= expression % }" { /> | > [<jsp:param  name="parameterName" 	
   value="{parameterValue | '${' Expression '}' | %= expression %}" }	
/> ]+ </jsp:forward> }

Examples

<jsp:forward page="/servlet/login" />
<jsp:forward page="/servlet/login">	
   <jsp:param name="username" value="jsmith" />	
</jsp:forward>

Description

The jsp:forward element forwards the request object containing the client request information from one JSP page to another resource. The target resource can be an HTML file, another JSP page, or a servlet, as long as it is in the same application context as the forwarding JSP page. The lines in the source JSP page after the jsp:forward element are not processed.

You can pass parameter names and values to the target resource by using a jsp:param clause. An example of this would be passing the parameter name username (with name="username") and the value scott (with value="scott") to a servlet as part of the request. If you use jsp:param, the target resource should be a dynamic resource that can handle the parameters.

Be careful when using jsp:forward with unbuffered output. If you have used the page directive with buffer="none" to specify that the output of your JSP page should not be buffered, and if the JSP page has any data in the out object, using jsp:forward will cause an IllegalStateException.

Attributes

See Also



宏飞网络是你学习web开发、测试web程序实例、和培养职业技能的首选网站。我们提供例子也许有些简单,但对理解基本概念有帮助。

我们尽量避免在教程、参考及例子中出现错误,但不能保证所有的内容都是正确的。

你使用本网站时,我们默认你已经阅读并接受了我们的隐私政策。

Copyright 2003-2011宏飞网络 版权所有