File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes can we maintain a javascript variable in session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "can we maintain a javascript variable in session" Watch "can we maintain a javascript variable in session" New topic

can we maintain a javascript variable in session

rachana ravali
Ranch Hand

Joined: Jun 20, 2006
Posts: 32
Hi ,
I am new to javascript and java.Please help i am having the following problem :
i have to set a variable when any change is made in a jsp page.
i am using onChange for that and calling a javascript function to set the variable.
problem is that i have to maintain the value as changed (if any data in the table is changed) even if the user goes to some link like help and return back to the table page.

thanks in anticipation.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

There really isn't a good way of doing this with just Javascript. You are going to need to get that data available on the server to persist in some way (Session maybe). Without knowing more details about what you are actually doing it's hard to give you a good solution. Ajax *might* work here, but I hate to say anything for sure without more information.

GenRocket - Experts at Building Test Data
Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
possible answers are: a. client, b. server.

1) Where is the javascript engine?

2) Where is a JSP parsed/translated?

This may seem very basic, sorry. We'll get to the answer.

- whoops, fixed a link.
[ May 16, 2007: Message edited by: Garrett Smith ]

comp.lang.javascript FAQ:
It is sorta covered in the JavaRanch Style Guide.
subject: can we maintain a javascript variable in session
It's not a secret anymore!