CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    20

    Getting Session Attributes in a servlet.

    Hi all,

    Here we are using the properitory Framework, so Iam not sending Code Sinppet.

    I have an application, where a servlet renders a Graph Image.

    In that servlet, based on Price or Units of Goods, it builds Y-Axis. And it is coded to display "$" symbol on Y-Axis.

    Requirement:
    For Units on Y-Axis, do not append "$".
    For Prices on Y-Axis, do append "$".

    So what Iam doing is, Iam setting a flag in Session to know wheather Y-axis is Units or Prices, and trying to get the Session, and therefore Attribute.

    Iam unable to do it. Is there any other way to do the above task?

    Thanks and Regards.

  2. #2
    Join Date
    Apr 2001
    Location
    South Africa, Jo'burg
    Posts
    680

    Re: Getting Session Attributes in a servlet.

    Hi,

    To get the session:
    Code:
    // Will return the currreent session, if 1 doesn't exists will return null
    request.getSession(false);
    //    OR
    // Will return the currreent session, if 1 doesn't exists will create a new one
    request.getSession(true);
    Then to get the attribute:
    Code:
    request.getSession(false).getAttribute("MyAttributeName");
    Hope This Helps
    Byron Tymvios

    Please use [ CODE ] and [/ CODE ] tags when posting code! See THIS on how to use code tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured