tags:

views:

31

answers:

1

Hi all,

I've a jsp page which saves a request parameter inside a javascript variable. Say a user visits the page through a wish list then the param fromWishList is set to 1, if the user visits this page from other source then there is no param called fromWishList.

//following code is inside a jsp page
<script type="text/javascript">
  var isWishList = '<c:out value="${param.fromWishList}" />';
    if(isWishList != ''){
      //page visited via wishList
    } else {
      //page visited via other sources
    }
</script>

Now my problem is that if a user visits the page via wish list the javascript var isWishList is set permanently set to '1', so that if the same user visits the page again via other sources the isWishList is still set to '1'. In the second case i wanted it to be blank.

I'm struggling with this since long time. I appreciate any help.

A: 

Try to take a look at the generated html code in your browser to see what values in both cases are assigned to the isWishList variable. You check for the empty string ''. You might better check for the string '1' because in the other case the value might be something like 'null' or similar. Don't know what jsp renders in this case.

Christian