The difference between getattribute () and GetParameter

Source: Internet
Author: User

When a forwarding relationship is made between two Web components, the forwarding source will share the data in the request scope first with setattribute to put the data into the HttpServletRequest object, and then forward the target through getparameter and GetParameter () method to obtain the request parameters, such as assuming a link relationship between welcome.jsp and authenticate.jsp, with the following code in WELCOME.JSP:

authenticate.jsp

Or:


Please enter user name:

Through the request in authenticate.jsp. GetParameter ("username"); %>

(3)getattribute () method to share data in the Request,session range with the forwarding source component.

Assume that there is a forwarding relationship between authenticate.jsp and hello.jsp. Authenticate.jsp want to pass the current user name to hello.jsp, how to pass this data? First call the SetAttribute () method in authenticate.jsp:

<%
String Username=request. %>

In hello.jsp through getattribute("username"); %>
Hello: <%=username%>

From a deeper level of consideration, request. GetParameter The () method returns data of type String.

Request.setattribute () and getparameter() are obtained through the implementation of the container to obtain data that is passed in such a way as post,get.

Request.setattribute () and getattribute are return objects, and thegetattribute() method returns objects that exist in the Reques,sessiont scope, and request. GetParameter () method is to get the data submitted by HTTP.

The difference between getattribute () and GetParameter

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.