Accessing httpsession in portletsession,

Hi,

I have a problem with accessing httpsession attribute in portletsession,

I am able to get the session set inside the portletsession as shown in the below code,

Servlet class code,

-

request.getSession(false).setAttribute(IPConstants.PRODUCTS+ownerId,products);

RequestDispatcher dispatcher = getServletContext().getRequestDispatcher( response.encodeURL("/ip/invPrc") );

dispatcher.forward( request, response );

portlet class code,(inside doview)

-

PortletSession session = request.getPortletSession(false);

if((RenderRequest)session.getAttribute("Invoice_Search_ses",1)!=null){

request = (RenderRequest)session.getAttribute("Invoice_Search_ses",1);

}

but when I try to set a attribute in httpsession inside servlet,

note :the servlet call was made thro the activexobject(ajax) from jsp as shown below,

reqobj = new ActiveXObject("MSXML2.XMLHTTP.3.0");

reqobj.open("POST", "<%=IPHelper.getContextPath(request)+"/"+IPConstants.SERVLET_URL_INVOICE_SEA RCH%>", true);

reqobj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

reqobj.onreadystatechange = loadSearchHandler;

reqobj.send(parameters);

servlet code,

--

request.getSession(false).setAttribute("Test_Naveen","Naveen");

out.print("<" + IPConstants.SERVLET_RESULT_ROOT + ">");

.

.

.

out.print("</" + IPConstants.SERVLET_RESULT_ROOT + ">");

i am not able to access the above session attribute in the portletsession.

I doubt since it is a call thro ajax, the session attribute is not applied on to the application scope. is there any other way to set the httpsession explicitly in the application scope which i am missing?

please help me in resolving this ?.

[1861 byte] By [Naveenperia] at [2007-11-26 16:55:32]
# 1

In order to share attributes across the HttpSession/PortletSession, you must specify PortletSession.APPLICATION_SCOPE. Application scope is the default in your servlet, but you must specify it in your portlet to get at the attributes stored.

Also, see my technical article on using HttpSession/PortletSession and AJAX in portlets:

http://developers.sun.com/prodtech/portalserver/reference/techart/ajax-portlets .html

The code is in the portlet repository:

https://portlet-repository.dev.java.net/

ziebolda at 2007-7-8 23:23:14 > top of Java-index,Web & Directory Servers,Portal Servers...