PageContext and Session in JSP

PageContext

A PageContext instance provides access to all the namespaces associated with a JSP page, provides access to several page attributes, as well as a layer above the implementation details. Implicit objects are added to the pageContext automatically.

session

Provides a way to identify a user across more than one page request or visit to a Web site and to store information about that user.

PageContext has a set of attributes that are different from the Session object.

The attributes set on PageContext are only available for a given page. The attributes are not available to other pages or servlets in the application.

Session attributes are created per each user's session. The session attributes are unique to a given session id. Session attributes are available to other pages and servlets in the application for a given session id.

Note:

  • The PageContext is implicitly instantiated by the application server.
  • The JSP page will always have access to the PageContext.
  • Session would be expired after 30 minutes when idle or closed the browser.

Reference:

https://tomcat.apache.org/tomcat-8.0-doc/jspapi/javax/servlet/jsp/PageContext.html

https://tomcat.apache.org/tomcat-8.0-doc/servletapi/javax/servlet/http/HttpSession.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • =========================================================...
    lavor阅读 3,505评论 0 5
  • 若雅 你曾 用手抚去我嘴角的饭粒 那天边的晚霞 恰好映在我我的双颊 你曾 与我执手相看星宿 那闪耀的群星却藏在你...
    刘若雅阅读 309评论 5 4
  • 小时候,她 优雅、博学、亲和 渺小的我 因为她而勇敢的梦 去追,去拼搏 长大后,我便成了她 无助、疲倦、艰辛 席卷...
    珺柒斋阅读 162评论 0 0
  • 俗话说,“冬养三九补品旺,夏治三伏行针忙”,而且冬病夏治由来已久,备受大众青睐。三伏天是一年中最热的时候,也是疾病...
    养生猫阅读 676评论 1 1
  • 今天进行了〈全员生发〉回流会,看着大家的讲解都很好,只有自己不在状态,讲的不到位 找核心 :没有认真的读笔记 转身...
    Tracy_zhang阅读 90评论 0 2