Comparison between request. getparameter and request. getattribute (Appendix: Problem 1)

Source: Internet
Author: User

The httpservletrequest class includes both the getattribute () method and the getparameter () method. The two methods have the following differences:

(1) The httpservletrequest class has the setattribute () method instead of the setparameter () method.

(2) When two Web components are linked, the linked component obtains the request parameters through the getparameter () method,

(3) When the forwarding relationship is between two Web components, the forwarding target component shares the data within the request range with the conversion source component through the getattribute () method.

Bytes ----------------------------------------------------------------------------------------------------------

Encountered a problem:

Set
Req. setattribute ("interval num", interval num );
Req. getrequestdispatcher ("/app? Service = external/login "). Forward (req, resp );

Get another page

String shortnum2 = Req. getattribute ("shortnum ");
String parameter num = Req. getparameter ("parameter num ");
The obtained values are the same. Why is the request. getparameter more widely used ??

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.