欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Aplication Request Session Page scopes 博客分类: JSP技術 applicationrequestsessionpageContext 

程序员文章站 2024-02-16 08:08:34
...
The most of the time you'll be using one of the four implicit objects to get and set attributes corresponding to the four attribute scopes available in a jsp. Remember ,in addition to the standard servlet request,session,application(context) scopes,a JSP adds a fourth scope-----page scope that you get from a pageContext object.

                 Application

In a servlet:     getServletContext().setAttribute("foo",barObj);
In a JSP    :     application.setAttribute("foo",barObj);

                Request

In a servlet:    request.setAttribute("foo",barObj);
In a JSP    :   request.setAttribute("foo",barObj);

                 Session

In a servlet:   request.getSession().setAttribute("foo",barObj);
In a JSP    :   session.setAttribute("foo",barObj);

                Page

In a servlet:   Does not apply!!!
In a JSP    :   pageContext.setAttribute("foo",barObj);