• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Manipulating session variables: urgent plz

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
i want to manipulate a session variable in page onload function. the variable is an enumeration. here is the example code
function pageload(){
<% itemEnum=(Enumeration) session.getAttribute("addedItems"); %>
if( <%= itemEnum%> == null)
alert("Null");
else
alert("notnull");
}
the first time the page loads(the enumeration is null) it works fine i.e. alert("null")
when the form is submitted to a servlet, the enumeration gets a value and request redirected to this page again and than it shows a javascript error of
Object Expected for itemEnum i think.
plz any one help me out with it.
thanks
Gul
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I know what your problem is:
Can you do a view source of the page so I can see what is sitting there after the page loads.
I think that the serverside variables are not doing what they are suposed to do.
Fix with a variable and quotation marks.....
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric's suggestion of looking at the HTML and Javascript that is sent to the browser (via view source) is an execellent one. I'm willing to bet that you will find that it is not what you intended.
bear
 
Gul Khan
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot the value returned was like
VALUE rather than "VALUE" in the javascript method.
I think the problem is in <%= test%> which uses out.println(test) and writes the value at its place there which the script takes as a variable rather than a string.
Will put that in quotes and try again.
Thanks alot once again.
Gul
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic