cancel
Showing results for 
Search instead for 
Did you mean: 

http session that's driving me crazy

Former Member
0 Kudos

Hi,

I have a very basic issue. I try to store data from a JSPDynpage to the httpSession, which is read by a jsp.

I can set data in the http Session object from an AbstractPortalComponent, but setting the session object from a JSPDynpage is not working. In the example below, the JSP shows "no data from http session". Who can help me with this:

<b>Dynpage:</b>

    public void doInitialization(){
		IPortalComponentRequest componentRequest = ((IPortalComponentRequest)getRequest());
		IPortalComponentSession componentSession = ((IPortalComponentRequest)getRequest()).getComponentSession();
		componentSession.getHttpSession().setAttribute("myData","data stored in http session by dynpage");

    }

<b>JSP:</b>

<% 
Object o =  componentRequest.getComponentSession().getHttpSession().getValue("myData");
String data = "no data from http session" ;
if (!(o==null)) data = o.toString();
%>


	<%=data %>

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Douglas,

getValue is deprecated.

Use getAttribute instead.

(See http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpSession.html)

Hope that helps,

Yoav.

Former Member
0 Kudos

Yoav,

Thanks for the remark. But I had tested it using this method. The strange thing is that I CAN set the data in the http sessionfrom an abstractPortalComponent, but it isnot working from a dynpage.

I'll email this par file (including source code)to you. It is a very basic example, may be you can test it.

Thanks for your help.

Ryan

Former Member
0 Kudos

Hi Ryan,

you can use the implicit session object in jsp.

Code in JSPDynpage:

((IPortalComponentRequest) getRequest()).getComponentSession().getHttpSession().setAttribute("A1","ok");

Code in JSP:

<% String text=(String)session.getAttribute("A1");%> 

Works perfectly.

Darryl just stated in the debug thread, that your component is set to jspnative. This is a NDS bug. Your JSPDynpage will never be called then! I think removing the property will solve your session problem as well

Regards, Karsten

Former Member
0 Kudos

The problem didnot lie in the java code, the problem had to do with a setting in the portalapp.xml file. Thanks to Darrel i was able to solve it.

The ComponentType has to be set to "none".

When you create a JSPDynpage using the wizard in NWDS the wizard sets this variable to "jsp" which causes the Dynpage component never to be executed.

Regards,

Ryan

Former Member
0 Kudos

That's what I said a few lines above.

Regards, Karsten