In J2EE, getParameter, getAttribute, and EL expressions $ {requestScope} and $ {param

Source: Internet
Author: User

GetParameter

① All the results are of the String type. Like http://name.jsp? Xy in name = xy

② Obtain the parameter value passed by POST/GET

③ Used for client redirection. For example, when you click a link or submit a button, it is used to receive data when using form or url redirection for value passing.

 


GetAttribute

① The retrieved type is Object.

② Used for server-side redirection, that is, using the forward function in sevlet or the getter/setter attribute in struts. GetAttribute can only receive values sent from the program using setAttribute.

③ Session. getAttribute () can obtain the session

 


EL expression

You can use the expression language to directly obtain the request parameter value. You can obtain the specified attribute value of the JavaBean on the page, the request header, and page, request, session, and application.

EL expressions have 11 built-in objects

PageContext
Pagination
RequestScope
SessionScope
ApplicationScope
Param
ParamValues
Header
HeaderValues
InitParam
Cookie

If you use request. setAttribute ("name", "xy") in the request field, you can use $ {requestScope. name}

Such as xy. jsp? Name = xy, which must be obtained through $ {param ["name "]}

 

Related Article

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.