cancel
Showing results for 
Search instead for 
Did you mean: 

Web Dynpro Session

Former Member
0 Kudos

I apologize if this has been discussed before. However, I could not find the answer on the forum.

I have read on the forum it is not possible to access the HttpSession object from Web Dynpro.

What is the best approach then to store objects per browser session?

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi Harm,

Check this one, may be it would be useful

And check this too

Best regards, Maksim Rashchynksi.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Harm,

It is not true that you cannot access the HttpSession object in a Web Dynpro, the thing is that is not supported by SAP, here is the code.


HttpServletRequest request = ((IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest();	
	HttpServletResponse response = ((IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletResponse();
	HttpSession sesion = request.getSession();

For this you will have to add servlet.jar to your build path.

A better way to mannage data is using the Context of a Web Dynpro View o Controller, I suggest you read this document

<a href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial%20on%20creating%20an%20extended%20web%20dynpro%20application%20-%202.htm">https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial%20on%20creating%20an%20extended%20web%20dynpro%20application%20-%202.htm</a>

which has the basic step for creating context and mapping it.

Regards.

*Remember rewarding point if the ansewear was helpful.

Former Member
0 Kudos

Hi,

I have used the same code for session in WebDynpro. But I am unable to find jar file required for IWebContextAdapter class. Can you please let me know the what is the jar file required for IWebContextAdapter.