www.webdeveloper.com
Results 1 to 2 of 2

Thread: getAttribute giving two different values based on how the URL is passed

  1. #1
    Join Date
    Mar 2010
    Location
    Nebraska
    Posts
    21

    Post getAttribute giving two different values based on how the URL is passed

    After much 'Topeking' (googling), I am still perplexed on my issue so i am going to describe this to the forum to see if anyone here can solve this.

    I am altering a JSP page that right now just calls another page directly and sends a few parameters which looks similiar to this
    1.
    Code:
    <a href="/mypage.jsp?parm1&parm2" >my page</a>
    Now i am adding a second link to this page which will call a servlet that will do some processing before redirecting it to the same next page, which looks similiar to this

    2.
    Code:
    <a href="/myservlet">mypage</a>
    This all works fine and as expected no problem. But now on my second page "mypage.jsp", I have a getAttribute method which I am expecting this method to return a null value the first time i hit this page and returns a vector every other time.

    So i have the following code

    Code:
    Vector myVector = (Vector)session.getAttribute("MyValues");
    int sizeOfVector = 0;
    if(myVector == null)
    {
         myVector = new Vector();
    }
    else
    {
        sizeOfVector = myVector.size();
    }
    Okay so far so good. Everything works as expected when using the (2) link myVector == null, but when using the first link (1) I get an empy undelcared Vector (myVector == []) but not a null one as i am expecting. Can anyone explain this? And what would I need to do to get around this? Thanks in advance

  2. #2
    Join Date
    Mar 2010
    Location
    Nebraska
    Posts
    21

    resolved

    fix found.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles