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

后端 未结 5 1342
夕颜
夕颜 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:52

    I actually have a real scenario in my app for its usage. We have Squid acting as a reverse proxy in front of our application. The squid server is set up to poll all the tomcat instances hosting our application to verify that the servers are up and running, if they are not, Squid will fail over to using another server in our cluster.

    The actual polling to our app from Squid is set to poll a specific page in the app. Since Squid's poll is not actually a browser, it can't hold a session, which means that each poll to the server page would have tomcat create a session which Squid cannot hold a reference to. We add the <%@ page session="false" %> directive so that a session is not created on each poll. If we did not use this directive, we would have thousands of sessions created over 4 hours time for no reason.

提交回复
热议问题