Difference between getattribute getparameter of request in Servlet

Source: Internet
Author: User

Abstract online:

1. at a deeper level, the data transmitted by the request. getparameter () method will be transmitted from the Web Client to the Web server, representing the HTTP request data.
The request. getparameter () method returns string-type data.


The data transmitted by the request. setattribute () and getattribute () methods only exists in the Web Container and is in the web group with forwarding relationship.
Shared among devices. These two methods can be used to set object-type shared data.

Request. getparameter () is achieved through the implementation of the container to obtain data transmitted through methods such as post and get.
Request. setattribute () and getattribute () are only transferred within the Web Container and are only the request processing phase.
Getattribute is the returned object, and getparameter returns the string

In general, the request. getattribute () method returns objects in the request range, while
The request. getparameter () method is used to obtain the data submitted by HTTP.

 

 

2. Request is something that comes from the user, attributes come from
Session

 

3.use request. getparameter () when u are planning to fetch values from a
html/JSP page, and use requets. getattribute () when u want to fetch
attribute values which are set using request. setattribute () in a
servlet.

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.