java backed webscript get HttpServletRequest and httpSession
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2013 09:19 AM
I made a java backed web script and i want to access HttpServletRequest in order to store a variable in the http session.
Here is what i tried
what is the correct way ?
Thx
Here is what i tried
public class GetValidationProgressionBean extends DeclarativeWebScript { @Override protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { HttpServletRequest httpReq = ((WebScriptServletRequest) req).getHttpServletRequest(); //org.alfresco.repo.web.scripts.RepositoryContainer$BufferedRequest cannot be cast to //org.springframework.extensions.webscripts.servlet.WebScriptServletRequest" => WebScriptServletRequest wraps the HttpServletRequest ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); //returns null HttpServletRequest request = requestAttributes.getRequest(); //Exception due to requestAttributes = null HttpSession httpSession = request.getSession(); ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes() //No thread-bound request found: Are you referring to //request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? HttpSession session = ServletUtil.getSession(); //returns null … }
what is the correct way ?
Thx
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2013 10:20 AM
<java>
WebScriptSession session = req.getRuntime().getSession();
</java>
seems to do what i want
WebScriptSession session = req.getRuntime().getSession();
</java>
seems to do what i want