新的会话从applet连续servlet请求和管理bean之间产生? [英] New Session is created between consecutive servlet request from an Applet and a managed bean?

查看:114
本文介绍了新的会话从applet连续servlet请求和管理bean之间产生?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过参数betweeen小程序和JSF组件
因此,当输入文本框的值不同,它的结合支持bean使得连接到一个servlet。该servlet创建一个属性,并使用保存到HttpSession中(request.getSession(真))的setAttribute(名称,值)。

I want to pass parameters betweeen applet and jsf components So when a value of a input textbox changed, its binding backing bean makes connection to a servlet. The servlet create an attribute and save to HttpSession using (request.getSession(true)).setAttribute(name, value);

然后,在某些情况下,小程序将访问另一个servlet。这个servlet会尝试恢复保存会话previously的属性。

Then at some event, applet will access another servlet. This servlet will try to retrieve the Attribute saved to Session previously.

不过,每次,返回attirbute为创建新的会话,而不是为null。

However, everytime, the attirbute returned is null as the new session is created instead.

我的问题是:是会话应该坚持? (我查allowcookies,为WebLogic会话超时)

My question is: Is the session should be persist? ( I checked allowcookies, session timeout for weblogic)

如果是,什么可能去错了我的应用程序?

If yes, what might go wrong with my app?

非常感谢你的帮助。

问候
K.

推荐答案

会议通过的cookie支持。在JSP / Servlet环境中的cookie的名称是 JSESSIONID 。访问同一个会议上,小程序有火在头所需的会话cookie的请求。此外,您还需要确保该servlet正在运行/在同一个域中和上下文听。

Sessions are backed by cookies. In a JSP/Servlet environment the cookie name is jsessionid. To access the same session, the applet has to fire a request with the desired session cookie in the header. Also, you need to ensure that the servlet is running/listening in the same domain and context.

要启动,传递会话ID作为参数传递给小程序:

To start, pass the session ID as a parameter to the applet:

<param name="jsessionid" value="${pageContext.session.id}">

然后,在小程序连接的Servlet如下:

Then, in the Applet connect the Servlet as follows:

String jsessionid = getParameter("jsessionid");
URL servlet = new URL(getCodeBase(), "servleturl");
URLConnection connection = servlet.openConnection();
connection.setRequestProperty("Cookie", "jsessionid=" + jsessionid);
// ...

下面 servleturl 显然应该与Servlet的 URL模式的web.xml 。这应该给同一个会话回在servlet的 request.getSession()

Here servleturl obviously should match servlet's url-pattern in web.xml. This should give the same session back in the servlet on request.getSession().

这篇关于新的会话从applet连续servlet请求和管理bean之间产生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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