accessing Scoped Variables

Source: Internet
Author: User

To permit the JSP page to access the data, the servlet needs to use SetAttribute to store the data in one of the Locations: The HttpServletRequest, the HttpSession, or the ServletContext. Objects in these locations is known as "scoped variables," andthe expression language have a quick and easy-to-do To access them.

You can also has scoped variables stored in the PageContext object, it's much less useful because the servlet and The JSP page does not share PageContext objects. So, page-scoped variables apply only to objects stored earlier in the same JSP page, not to objects stored by a servlet. To output a scoped variable, you simply use the its name with an expression language element.

For example, ${name} means to search the PageContext, HttpServletRequest, HttpSession, and ServletContext (on that Ord ER) for the attribute named. If The attribute is found, it toString method is called and that result is returned. If Nothing was found, an empty string (not NULL or a error message) is returned.

So, for example, the following and the expressions are equivalent. ${name} <%= Pagecontext.findattribute ("name")%>

Http://pdf.coreservlets.com/JSP-EL.pdf

©prentice Hall and Sun Microsystems Press. Personal Use only

accessing Scoped Variables

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.