It's not a secret anymore!*
The moose likes Cattle Drive and the fly likes Technique for shared servlet data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Technique for shared servlet data" Watch "Technique for shared servlet data" New topic
Author

Technique for shared servlet data

Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 129
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)?


Darryl Failla
Sun Certified Java 2 Programmer
Sam Tilley
Ranch Hand

Joined: Dec 05, 2001
Posts: 160
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 ]

Sam Tilley SCJP, SCWCD
Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 129
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

Joined: Jul 22, 2000
Posts: 9048
    
  10
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


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Technique for shared servlet data