• Post Reply Bookmark Topic Watch Topic
  • New Topic

Storing Variables on a Web Server  RSS feed

 
Mike Hebear
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to store variables, integers etc, on the server for a web page? These variables are not specific to each person who logs on (so i only need to store a few variables total), but i dont want to re-do the calculation every time someone logs on, i want to store them on the server. Would you use servlets, applets, databases, textfiles, I just dont know. Any advice would be greatly appreciated.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a whole variety of ways for doing this, and it depends on your requirements which one suits best. If these values change intermitently, use a persistant store (RDBMS, file system etc.) or put set them in the ServletContext if you don't want the overhead of DB round trips. Or (if these values are read only) you could cache them in a singleton or some simmilar object. What you can't do is store anything application wide in a servlet. Nor can you store server-side values in an applet (since they are client side code).
 
Mike Hebear
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help! You said it depends on my requirements and what Im trying to do... I work on my high school webpage, and we run on a 7 day cycle. Im just trying to make the webpage display what day it is... but I have to enter valid school days, account for weekends and vacations, snowdays, etc... So Im trying to keep a list of all valid school days and compare it to the current date to see if it's a valid school day, and then assign it 1-7 depending on what day of the cycle it is. Thanks for your previous help, and anything more specific would be appreciated!
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You sure need a place-holder for your school holidays etc, to compare to the current day.
There are different ways to save this information. The easient being, saving as a flat file on your server and access through the servlets.
If you already have a basic database you can create above info into a table and then access using a DAO(sort of a JDBC query).
After you retrieve the above list of dates, compare with current date and submit and output your final date(1-7) on the final JSP.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!