Aplication Request Session Page scopes

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);

你可能感兴趣的:(session,request,application,pageContext)