为什么将JSP页面会话设置为"false"?指示? [英] Why set a JSP page session = "false" directive?

查看:78
本文介绍了为什么将JSP页面会话设置为"false"?指示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道您何时要在JSP中设置以下页面指令:

I was wondering when you would want to set the following page directive in a JSP:

<%@ page session="false" %>

我知道它阻止了会话对象的创建,但是您什么时候需要这样做?当JSP不需要访问隐式会话时,它是否被视为最佳实践?

I know that it prevents the creation of the session object, but when would you need to do that? Is it considered a best practice when a JSP does not need to access the implicit session?

注意:我之所以问,是因为这是在本Spring MVC教程中,并且我认为springsource的人们都知道他们的知识-推荐答案

一个原因是性能内存.如果您有不需要参与会话的页面(例如about.jspfaq.jsp),则在会话中涉及每个JSP的默认行为将增加创建新会话对象的开销. (如果还不存在的话),并且随着更多对象驻留在堆上而增加了内存使用量.

One reason would be performance and memory. If you have a page that doesn't need to be involved in a session (like say, an about.jsp or faq.jsp) then the default behaviour of involving every JSP in a session will impose the overhead of creating a new session object (if one doesn't already exist) and increased memory usage as more objects reside on the heap.

如果单个页面看到来自许多唯一身份用户的高流量以及较高的跳出率,即当用户查看该页面后,他们的用户不会继续浏览而是立即离开网站,则该效果将被大大夸大为每个用户创建一个新的会话对象,该对象将不再使用,并且在超时后最终将被垃圾回收-添加了对象创建,内存使用和垃圾回收的开销,而没有给您任何实际价值.

This effect will be greatly exaggerated in case of a single page seeing high traffic from many unique users combined with a high bounce rate i.e. they users do not continue to browse but leave the site immediately after viewing that one page- the container will create a new session object per user which will never be used again and will ultimately be garbage collected after it times out - added over head of object creation, memory usage and garbage collection without giving you any real value.

这篇关于为什么将JSP页面会话设置为"false"?指示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆