Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Changing variables dynamically

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hya!
At the moment I am trying to implement a small web site based on JSP and JavaScript with my group at university.
I have created some JavaBeans which keep information about some artists, the day they are to present a concert, the price of the tickets and how many there are available.
This information is brought back to the user once he makes any choice on his browser. The problem is that the number of tickets available is not changing dynamically. Actually this number is a JavaScript variable that always starts with the value 100.
I wonder how I could make this number change if every time a different user visits the page this number will be set to its first value, 100.
I would be grateful if one of you could give me some advice in this.
Yours,
Saulo
[ May 22, 2003: Message edited by: Saulo Menezes ]
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
If u r going to have a javascript variable it will be reinitialised for every browser refresh.
For reflecting the avaliable tickets u can follow 2 approaches.
1.One is after storing the ticket value in the database and after each user visits the site and books the tckt u can update the DB so that each user when chooses to view the available ticktes it would be the correct one.
2.Other is using application variable(putting the number of available tickets in the servlet context).This variable is available for all the users and when each user books a ticket u can update this variable value(ie current value minus 1).If a user chooses to look in for the number of available tckts he would get the current availablity taken from the servlet context.
Regards
Geeta
 
Ranch Hand
Posts: 250
Python Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also opt for generating the "javascript" dynamically. The initial value of "100" can be any value (say, incrementing on the last value fecthed from a query on your database). For ex:

HTH
 
reply
    Bookmark Topic Watch Topic
  • New Topic