Below sample method which will returned HttpServlet request.
import javax.portlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
private HttpServletRequest getHttpServletRequest(PortletRequest request){
HttpServletRequest httpServletRequest = (HttpServletRequest)request;
while(httpServletRequest instanceof HttpServletRequestWrapper){
HttpServletRequestWrapper httpServletRequestWrapper =
(HttpServletRequestWrapper)httpServletRequest;
System.out.println("HttpServletRequestWrapper " + httpServletRequestWrapper);
httpServletRequest = (HttpServletRequest)httpServletRequestWrapper.getRequest();
}
return httpServletRequest;
}
Below code snippet in doview
HttpServletRequest httpServletRequest = getHttpServletRequest(request);
javax.servlet.http.HttpSession httpesesion = httpServletRequest.getSession();
httpesesion.setAttribute("name", "test");
----------------------------------------------------------------
You can access session attribute in servlet. it is helpful in servlet written inside portlet. I have used to render PDF report in servlet.