【问题标题】:How to set session timeout in <glassfish-web-app> / glassfish-web.xml configuration file?如何在 <glassfish-web-app> / glassfish-web.xml 配置文件中设置会话超时?
【发布时间】:2015-10-11 17:30:55
【问题描述】:

我正在尝试在 &lt;glassfish-web-app&gt; / glassfish-web.xml 配置文件中设置会话超时,但它不起作用(使用 glassfish4 和 NetBeans):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">

    <context-root>/some-path</context-root>

    <class-loader delegate="true"/>

    <jsp-config>
        <property name="keepgenerated" value="true">
            <description>Keep a copy of the generated servlet class' java code.</description>
        </property>
    </jsp-config>

    <session-config>
        <session-timeout>10</session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

</glassfish-web-app>

但如果我创建如下所示的 ./WEB-INF/web.xml 文件,一切正常:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1"
         xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">

    <session-config>
        <session-timeout>10</session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

</web-app>

所以,但是有两个conf。文件:glassfish-web.xmlweb.xml。我可以在一个glassfish-web.xml 文件中以某种方式完成所有这些吗?

【问题讨论】:

    标签: netbeans glassfish-3 glassfish-4


    【解决方案1】:

    找到解决办法:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
    <glassfish-web-app error-url="">
    
        <context-root>/some-path</context-root>
    
        <class-loader delegate="true"/>
    
        <jsp-config>
            <property name="keepgenerated" value="true">
                <description>Keep a copy of the generated servlet class' java code.</description>
            </property>
        </jsp-config>
    
        <session-config>
            <session-properties>
                <property name="timeoutSeconds" value="600"/>
                <property name="enableCookies" value="false"/>
            </session-properties>
        </session-config>
    
    </glassfish-web-app>
    

    【讨论】:

      猜你喜欢
      • 2018-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-23
      • 2014-05-25
      • 1970-01-01
      • 2017-06-10
      相关资源
      最近更新 更多