• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Technique for shared servlet data

 
Darryl Failla
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have gotten Servlets 4a to work by making the data to be shared static within its own class. Is this the proper technique for this type of problem?
Also, what is the correct way to call an html page up from within a servlet after the servlet work is completed (jump back to the html page without user intervention)?
 
Sam Tilley
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also used made the data in the mystery file static but marilyn came back and said that i am not supposed to use a global variable (which i take to mean a class variable) which i suppose meant that you should create an object of the class, but then it gets even trickier
To jump back to an HTML page just put a link in as you would in HTML in the servlet which the user can click onto, you just need to find the right location of the html page on the server.
[ August 08, 2002: Message edited by: Sam Tilley ]

9/8/02 OKAY got ya, my mistake, didnt ready your email properly, aah and now i know what she meant by a global variable
[ August 09, 2002: Message edited by: Sam Tilley ]
 
Darryl Failla
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to me that in the web server environment, you can not guarantee that new instances of a servlet will not be created when needed. That being the case, how can you know that all servlets will be pointing to the same data unless the data is at the class level of your data class?
The other thing I am looking for is a way to redirect a servlet to a another web page WITHOUT user intervention.
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by darryl failla:
It seems to me that in the web server environment, you can not guarantee that new instances of a servlet will not be created when needed. That being the case, how can you know that all servlets will be pointing to the same data unless the data is at the class level of your data class?


Static is ok. public static is not ok.

The other thing I am looking for is a way to redirect a servlet to a another web page WITHOUT user intervention.


Are you sure you want to redirect the servlet? You may want to search the servlets forum regarding this as it is not really related to the CattleDrive assignments. here is a start
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic