[Building Sakai] Accessing HTTP Attributes in Sakai
Charles Severance
csev at umich.edu
Thu Dec 26 19:08:05 PST 2013
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> wrote:
> Following up on this, can someone confirm that the Sakai ContextSession object provides access to the current HTTP attributes? Thedocumentation 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/20131226/de7196f0/attachment.html
More information about the sakai-dev
mailing list