Skip to Content

Get session attribute from WebDynpro

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2007 at 08:45 PM

    IWDWebContextAdapter webContext = WebContextAdapter.getWebContextAdapter();

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

    Regards,

    Venkat.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2007 at 08:17 AM

    Hi Venkat,

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

    Thanks.

    Regards,

    Matteo.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2007 at 09:55 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2007 at 12:11 PM

    Hi Satyajit,

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

    Regards,

    Matteo

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • Posted on Nov 30, 2007 at 02:28 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.