cancel
Showing results for 
Search instead for 
Did you mean: 

Get session attribute from WebDynpro

matteodesantis
Explorer
0 Kudos

Hi All,

I need to get an attribute from my WebDynpro Project.

I set this attribute into a JSP page, with the instruction "session.setAttribute("mysessvar", "TEST");".

Now, how can I get this attribute from my WebDnpro?

Thanks.

Regard,

Matteo

Accepted Solutions (0)

Answers (5)

Answers (5)

matteodesantis
Explorer
0 Kudos

Hi Satyajit,

I have included your code in my WebDynpro, but I have this error:

"ScopeType.CLIENTWINDOW_SCOPE cannot be resolved".

In fact, I have three values: COMPONENT_SCOPE, NO_SCOPE, SERVERSESSION_AT_LEAST_ONE_APP_SCOPE.

If I choose one value, I have another error: "cannot convert from IMaintainScope to IScope".

I tried the cast, but I don't retrieve the value of my session attribute, because it go in the catch:

try {

IScope scope = (IScope)Utils.getScopeMaintainer(ScopeType.COMPONENT_SCOPE);

if(scope.containsKey("mysessvar")){

Object value = scope.get("mysessvar");

wdContext.currentContextElement().setMyVar(value.toString());

}

} catch (Exception e) {

// TODO: handle exception

}

Thanks,

regards.

matteodesantis
Explorer
0 Kudos

Hi Satyajit,

I have Netweaver ver. 2.0.17, the object WDScopeUtil cannot be resolved.

Regards,

Matteo

Former Member
0 Kudos

Hi,

Ok this is taboo and I am not supposed to give you this code piece (it will be deleted if the Moderators find out). Try this:

IScope scope = Utils.getScopeMaintainer(ScopeType.CLIENTWINDOW_SCOPE);
    	
if(scope.containsKey("<param_key>")){
   Object value = scope.get("<param_key>");
}

Do understand that this makes use of internal WD classes and is not supported in later releases of WD. I'm telling you this because you are on one of the earlier versions.

Regards,

Satyajit.

matteodesantis
Explorer
0 Kudos

Hi Venkat,

I have solved the previous error ("WebContextAdapter cannot be resolved"), but my variable is a session attribute, not a request parameter. I need necessarily to retrieve a session attribute.

Thanks.

Regards,

Matteo.

Former Member
0 Kudos

Hi,

If your WD application is invoked via the JSP page, you can try this:

WDScopeUtil.get(WDScopeType.CLIENTWINDOW_SCOPE, "<parameter key>");

Regards,

Satyajit.

matteodesantis
Explorer
0 Kudos

Hi Venkat,

I have an error: "WebContextAdapter cannot be resolved" (after I chose Source->Organize Import).

Thanks.

Regards,

Matteo.

Former Member
0 Kudos

IWDWebContextAdapter webContext = WebContextAdapter.getWebContextAdapter();

String param = webContext.getRequestParameter("mysessvar");

Regards,

Venkat.