cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with HTTP Session

Former Member
0 Kudos

Hello,

I am developing a WebDynpro application (several actually) that has to reuse attributes set in the HTTP session by another Portal application (HTMLB). Both applications are integrated in the same EP with iViews.

I can get the HTTP session using the WDWebContextAdapter class, but my attributes are not there. Seems there is only one attribute named "sap.webdynpro.clientsession".

Do you have an idea on what I am missing ?

Thanks a lot for your help.

Regards,

Nicolas

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Have you considered using portal eventing between the iViews instead. Portal eventing is the approved way you can pass data between iViews. What happens if in the future your web dynpro application runs in the Smart Client in the iView instead of as an HTML page? Even if you could get access to the HTTP session to work - would it continue to work in this situation?

Former Member
0 Kudos

Hello Thomas,

The problem is that the user navigates between the applications with the menu of the portal. How do you use portal eventing in that case ?

Regards,

Nicolas

Former Member
0 Kudos

So... ? How can I do in that case ?

Thanks,

Nicolas

Former Member
0 Kudos

Nicolas,

Try the following (I've suggested this several times, but no one reply with a follow-up, so I'm not sure whether or not it works):

In both applications get currently logged-in user. Then use transient attributes to share data: IUser.setTransientAttribute / IUser.getTransientAttribute.

VS

Former Member
0 Kudos

Valery,

Tried this yesterday too, but doesn't seem to work...

Here is my code :

1/ Set the attribute in the Portal app

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IUserContext user = request.getUser();
user.setTransientAttribute("my_ns", "test", "value_test");
log.errorT("--> transient attribute set for user " + user.getName());

2/ Read the attribute in the WDP app

IUser user = null;
try {
    user = WDClientUser.getCurrentUser().getSAPUser();
} catch (WDUMException e) {
    e.printStackTrace();
}
		
String val = (String) user.getTransientAttribute("my_ns", "test");
msgmgr.reportSuccess("getTransientAttribute = [" + val + "] for user " + user.getName());

But I always read a null value.

My 2 applications are integrated in the same portal with iViews.

Nicolas

Former Member
0 Kudos

Nicolas,

I'm not familiar with Portal-related API, but does it possible to get UME IUser in portla application? I guess there is some mismatch in your code: portal part uses IUserContext, but WD uses UME IUser.

VS

Former Member
0 Kudos

Valery,

That doesn't work either.

I now get the user like that :

IUser iuser = request.getUser();

In both applications, user is of type com.sap.security.api.IUser

Nicolas

Former Member
0 Kudos

Nicolas,

Just to make sure: try to output value of call System.identityHashCode( iuser ); in both applications. If values are different, then different IUser object is created, hence this way is wrong

VS

Former Member
0 Kudos

Valery,

Just tried this, and I get 2 different numbers, something like 13375109 and 19142683.

So this way is wrong...

Do you have another idea ?

Thanks a lot,

Nicolas

Former Member
0 Kudos

Nicolas,

according to your words:

<i>The problem is that the user navigates between the applications with the menu of the portal. </i>

So, if I understand correctly, passing data via URL parameters is not an option either (you cannot alter URL in question dynamically).

The only thing left is non-public API in WebDynpro for accessing underlying HttpRequest / HttpSession, but we will not discuss it due to reasons described here: /people/bertram.ganz/blog/2005/02/02/never-ever-hijack-internal-web-dynpro-classes-and-interfaces

VS

Former Member
0 Kudos

Valery,

Thanks a lot for your help.

So the only option left is to use non public APIs, and isolate them in one single place so that they can easily be updated if needed. I don't have the choice now.

Do you have samples of code ? Here is my email address : nicolas.boussuge AT gmail DOT com, if you don't want to discuss it there.

Regards,

Nicolas

Former Member
0 Kudos

Valery,

I tried using the set and get for the TransientAttribute

and it worked within the same WebDynpro Application.

I then tried to retrieve it from a second Webdynpro Application on another portal page and the attribute

was null.

Is there a final step that needs to happen to commit the

attribute to the User?

JC

Former Member
0 Kudos

John,

Read the whole thread again -- we concluded that this is wrong approach. Btw, there is no way to "commit" or "persist" tarnsient attributes, hence they have such name.

VS

Answers (0)