Why set a JSP page session = “false” directive?

后端 未结 5 1349
夕颜
夕颜 2020-11-29 22:25

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

<%@ page session=\"false\" %>

I know that it prevents th

5条回答
  •  无人及你
    2020-11-29 22:49

    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.

提交回复
热议问题