on 08-11-2005 9:28 AM
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 %>
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.