简体   繁体   English

Portlet - 从服务器端保持会话活动

[英]Portlets - Keeping session alive from server side

I am implementing jsr 186 portlets, with some servlets to the mix to implement some ajax. 我正在实现jsr 186 portlet,并将一些servlet用于实现一些ajax。 The problem is if I only make AJAX calls for some time, I lose the session. 问题是如果我只进行一段时间的AJAX调用,我会失去会话。 Strangely, keeping alive the servlet session does not prevent the portlet session from timing out. 奇怪的是,保持servlet会话的活动并不会阻止portlet会话超时。

Is there a way I can keep the session alive from within my servlets, on the server side? 有没有办法让我在服务器端的servlet中保持会话的活动状态?

FWIW I'm using spring and spring mvc/portlet. FWIW我正在使用spring和spring mvc / portlet。

Thanks, Miguel Ping 谢谢,米格尔·平

I had the same problem. 我有同样的问题。 (Using OpenPortal Portlet Container) (使用OpenPortal Portlet容器)

As I know there is two different sessions, 1- portlet session, 2- Container session. 据我所知,有两个不同的会话,1个portlet会话,2个容器会话。

I created a simple portlet and made request to the portlet with ajax periodically from container. 我创建了一个简单的portlet,并定期从容器向portlet请求ajax。 However, session times out. 但是,会话超时。 My code fraction is here: 我的代码分数在这里:

<%
    int per=15000; //ms
    String sessionExtenderPath = "http://portal.abc.com.tr:8080/SessionExtend/SessionExtend";
    //This is a portlet which includes servlet that returns a simple string.
%>

<script>
    periyod=100;

    function invokeRequest(){
     $.get("< %=sessionExtenderPath% >", function(data) {
      alert(1);
     });
    }
    window.setInterval("invokeRequest()",periyod);
</script>

I have solved my problem by requesting container page (wihout defining a channel for a portlet). 我通过请求容器页面解决了我的问题(没有为portlet定义通道)。

Thanks for edit. 谢谢你的编辑。

I implemented it using a javascript timer that kept polling a portlet url. 我使用javascript计时器实现它,该计时器保持轮询portlet url。 The portlet url was generated beforehadn so it was accessible in javascript. portlet url是在beforehadn之前生成的,因此可以在javascript中访问它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM