Difference between getAttribute () and getParameter: attribute and parameter

Source: Internet
Author: User

Difference between getAttribute () and getParameter: attribute and parameter

When the forwarding relationship is between the two Web components, the conversion source will share the data within the request range and put the data into the HttpServletRequest object with setAttribute, and then forward the data to the target throughGetParameterAndGetParameter() Method to obtain Request Parameters. For example, if the link between welcome. jsp and authenticate. jsp is a link, the following code is available in welcome. jsp:

Authenticate. jsp

Or:


Enter the User Name:

In authenticate. jsp, request.GetParameter("Username"); %>

(3)The getAttribute () method shares the request and session data with the conversion source component.

Assume that the relationship between authenticate. jsp and hello. jsp is forwarding. Authenticate. jsp wants to pass the current username to hello. jsp. How can this data be transmitted? First, call the setAttribute () method in authenticate. jsp:

<%
String username = request.%>

In hello. jspGetAttribute("Username"); %>
Hello: <% = username %>

From a deeper perspective, request.GetParameter() Method returns data of the String type.

Request. setAttribute () andGetParameter() Data is obtained through the implementation of the container and transmitted through methods such as post and get.

Request. setAttribute () andGetAttributeIs the returned object,GetAttribute() Method returns the objects in the reques, sessiont range, and request.GetParameter() Method is to obtain the data submitted by http.

 

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.