Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlets and weblogic

 
mikey mikey
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a question and I hope someone can help me. I am creating a servlet, that is called everytime there is an action on JSP web page. What I want to do is load several Trees, vectors, and one bean, I want to only have to load these items the first time that I initialize the servlet. This succeeds in Tomcat but not in weblogic. Does anyone have any ideas? I would really appreciate it.
thank you
------------------
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All servlets have an init() method that is called when the servlet is first loaded. You can perform your object initialization in this method, or, you can create a static block in your servlet that will execute when the class is loaded by the JVM. The only downside for the latter is that you can only access static methods and data in a static initializer, you cant access instance variable.
SAF
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic