portlet—从服务器端保持会话活动

时间:2021-08-19 16:42:40

I am implementing jsr 186 portlets, with some servlets to the mix to implement some ajax. The problem is if I only make AJAX calls for some time, I lose the session. Strangely, keeping alive the servlet session does not prevent the portlet session from timing out.

我正在实现jsr 186 portlet,并使用一些servlet来实现一些ajax。问题是,如果我只调用AJAX一段时间,就会丢失会话。奇怪的是,保持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.

我正在使用spring和spring mvc/portlet。

Thanks, Miguel Ping

谢谢,米格尔平

2 个解决方案

#1


1  

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- Container会话。

I created a simple portlet and made request to the portlet with ajax periodically from container. However, session times out. My code fraction is here:

我创建了一个简单的portlet,并定期从容器中使用ajax向portlet发出请求。然而,会话超时。我的代码分数在这里:

<%
    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.

谢谢编辑。

#2


0  

I implemented it using a javascript timer that kept polling a portlet url. The portlet url was generated beforehadn so it was accessible in javascript.

我使用保持轮询portlet url的javascript计时器实现了它。portlet url是在之前生成的,因此可以在javascript中访问它。

#1


1  

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- Container会话。

I created a simple portlet and made request to the portlet with ajax periodically from container. However, session times out. My code fraction is here:

我创建了一个简单的portlet,并定期从容器中使用ajax向portlet发出请求。然而,会话超时。我的代码分数在这里:

<%
    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.

谢谢编辑。

#2


0  

I implemented it using a javascript timer that kept polling a portlet url. The portlet url was generated beforehadn so it was accessible in javascript.

我使用保持轮询portlet url的javascript计时器实现了它。portlet url是在之前生成的,因此可以在javascript中访问它。