<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>GET HTTP Session from serve resource</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=89026005" />
  <subtitle>GET HTTP Session from serve resource</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=89026005</id>
  <updated>2026-04-07T01:53:41Z</updated>
  <dc:date>2026-04-07T01:53:41Z</dc:date>
  <entry>
    <title>RE: GET HTTP Session from serve resource</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89029394" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89029394</id>
    <updated>2017-05-03T22:10:50Z</updated>
    <published>2017-05-03T22:10:50Z</published>
    <summary type="html">Yes there is a solution - avoid the session altogether.&lt;br /&gt;&lt;br /&gt;Now that doesn&amp;#39;t mean it has to be retrieved each time.  You can, for example, leverage a SingleVMPool or MultiVMPool (for a cluster) which pushes retrieved values into a cache that is backed by ehcache and so it will expire and discard values.  So basically you check the cache and, if it doesn&amp;#39;t have the value, retrieve from remote service and store back in the cache.&lt;br /&gt;&lt;br /&gt;But session storage is always, always a bad idea and a terrible hack.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="https://www.eventbrite.com/e/liferay-symposium-north-america-2017-registration-28398031276"&gt;Come meet me at the 2017 LSNA!&lt;/a&gt;</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2017-05-03T22:10:50Z</dc:date>
  </entry>
  <entry>
    <title>RE: GET HTTP Session from serve resource</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89029274" />
    <author>
      <name>ibrahim magdy</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89029274</id>
    <updated>2017-05-03T21:37:43Z</updated>
    <published>2017-05-03T21:37:43Z</published>
    <summary type="html">thanks for your reply &lt;br /&gt;&lt;br /&gt;in my case i need to store a value that comes from external service which will be the same across the session and i want to access it while i make ajax calls so how can i achieve that when i have new session with every ajax call is there any alternative rather than keep it in the session</summary>
    <dc:creator>ibrahim magdy</dc:creator>
    <dc:date>2017-05-03T21:37:43Z</dc:date>
  </entry>
  <entry>
    <title>RE: GET HTTP Session from serve resource</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89026244" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89026244</id>
    <updated>2017-05-03T21:23:30Z</updated>
    <published>2017-05-03T21:23:30Z</published>
    <summary type="html">They are not guaranteed to be the same session.&lt;br /&gt;&lt;br /&gt;A render request is basically issued by the portal when it&amp;#39;s main servlet is collecting content to aggregate a page.  Therefore the request that you get in your portlet originates from the ROOT web application.&lt;br /&gt;&lt;br /&gt;Serve resource requests, though, well they can go directly through your own portlet war, so it&amp;#39;s through your own web app and therefore has your own session, not the portal session.&lt;br /&gt;&lt;br /&gt;This is another reason to avoid session storage, as I&amp;#39;ve said before it is a miserable hack to begin with and it doesn&amp;#39;t play well in a cluster.  Whatever you&amp;#39;re trying to store in the session should be persisted in a classic sense, not the hack of the session store.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="https://www.eventbrite.com/e/liferay-symposium-north-america-2017-registration-28398031276"&gt;Come meet me at the 2017 LSNA!&lt;/a&gt;</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2017-05-03T21:23:30Z</dc:date>
  </entry>
  <entry>
    <title>GET HTTP Session from serve resource</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89026004" />
    <author>
      <name>ibrahim magdy</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89026004</id>
    <updated>2017-05-03T20:17:36Z</updated>
    <published>2017-05-03T20:17:36Z</published>
    <summary type="html">Hi every one,&lt;br /&gt;i am trying to get Http session from serve resource method i use the following lines&lt;br /&gt; &amp;#34;HttpServletRequest org = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(request));&lt;br /&gt;			  log.info(&amp;#34; session id =&amp;#34;+org.getSession().getId());&amp;#34;&lt;br /&gt;&lt;br /&gt;but the session id printed is totaly different than the real http session id&lt;br /&gt;&lt;br /&gt;note : when i use the same lines of code on render method not serve resource methods it works fine and return the same id</summary>
    <dc:creator>ibrahim magdy</dc:creator>
    <dc:date>2017-05-03T20:17:36Z</dc:date>
  </entry>
</feed>
