[Building Sakai] Accessing HTTP Attributes in Sakai
Mark J. Norton
markjnorton at earthlink.net
Fri Dec 27 04:05:13 PST 2013
Thanks, Chuck. This is interesting information. I did find a similar
technique to get the Tomcat SessionContext via ThreadLocalManager, but I
wasn't aware that the HttpRequest was kept there as well. Fortunately,
the situation I am dealing with has a fall back if the HttpRequest is
not there or is invalid.
- Mark
On 12/26/2013 10:08 PM, Charles Severance wrote:
> Mark,
>
> I don't know if this helps, but I found myself stuck inside of Portlet
> code unable to get a GET parameter in the Servlet request. The
> Portlet API works very hard to *not* give you access to the real
> underlyingServlet request - but inside of Sakai, I made this work:
>
> ./basiclti-portlet/src/java/org/sakaiproject/portlets/IMSBLTIPortlet.java
>
> ...
> import javax.servlet.ServletRequest;
> import org.sakaiproject.thread_local.cover.ThreadLocalManager;
> ...
> public final static String CURRENT_HTTP_REQUEST =
> "org.sakaiproject.util.RequestFilter.http_request";
> ...
> // Grab that underlying request to get a GET parameter
> ServletRequest req = (ServletRequest)
> ThreadLocalManager.get(CURRENT_HTTP_REQUEST);
> String popupDone = req.getParameter("sakai.popup");
>
> Your mileage may vary - within Portlet UI View method so I knew
> exactly where in the request lifecycle I would always be. In library
> code It might not be so clear where you are at in the request /
> response cycle... One call from a tool might work and a call from
> Quartz will blow up with an NPE. Caveat emptor.
>
> Good luck.
>
> /Chuck
>
>
> On Dec 26, 2013, at 9:08 AM, Mark J. Norton <markjnorton at earthlink.net
> <mailto:markjnorton at earthlink.net>> wrote:
>
>> Following up on this, can someone confirm that the Sakai
>> ContextSession object provides access to the current HTTP
>> attributes?
>> Thedocumentation<https://source.sakaiproject.org/svn/kernel/trunk/api/src/main/java/org/sakaiproject/tool/api/ContextSession.java>is
>> a bit sparse. ContextSession.getAttribute() has the comment:
>> Returns the object bound with the specified name in this session, or <code>null</code> if no object is bound under the name.
>> I just need to be sure that the "session" here is the HTTP session,
>> rather than the Sakai session.
>>
>> - Mark
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20131227/21b2be8e/attachment.html
More information about the sakai-dev
mailing list