【问题标题】:Session Replication on JBoss EAP is not workingJBoss EAP 上的会话复制不工作
【发布时间】:2014-01-18 10:18:14
【问题描述】:

我正在尝试让会话复制工作...我们有两个节点,我在节点 1 上启动以下 JSP 代码,我观察计数器上升。然后我关闭节点,我认为计数器会仍然有权利并在 node2 上工作。我们确实被转移到 node2,但它开始了一个新会话。

下面是JSP代码:

<% /*
This is an example that shows sessions in use within a JSP.

It's the simplest possible demo - a visit counter, but a
counter for the number of times that the current user has
visited during the current session.
*/

/* Get value, or set to zero if this is a new session */

String val = (String) session.getAttribute("previouses");
if ( val == null ) val = "0";

/* Convert to number, increment, save back into session */
int n = Integer.parseInt(val);
n++;
session.setAttribute("previouses",Integer.toString(n));

/* Also pick up the hosts so that we can echo this in the
reply page (great for testing load balancer and sticky
session algorithms on our training courses! */
String hostipr = request.getRemoteHost();
String hostipl = request.getServerName();

/* ------------------------------------------------- */

%>
<html>
<head>
<title>Sessions using a JSP</title>
</head>
<body>
<h1>Sessions in a JSP</h1>
This example program shows the use of a session within a
Java Server page (JSP). It's the simplest possible example,
counting the number of times that the user has visited in
the current session.<br /><br />
<b>Details from the session</b><br/>
Requested session:<%=request.getRequestedSessionId()%><br/>
Session: <%= session.getId()%><br/>
Generating or back end host: <%= hostipl %><br />
Accessing or front end host: <%= hostipr %><br />


Count: <%= n %><br/>
</body>
</html>

【问题讨论】:

    标签: java spring jsp session jboss


    【解决方案1】:

    您需要为 JBoss 提供带有 &lt;distributable/&gt; 标签的 web.xml,以便为您的 Web 应用程序启用会话复制。参考http://docs.jboss.org/jbossas/docs/Clustering_Guide/beta422/html/clustering-http-app.html

    【讨论】:

    • 我确实在 web.xml 中有那个
    猜你喜欢
    • 1970-01-01
    • 2013-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-30
    相关资源
    最近更新 更多