This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hi, Is there any equivalence of global.asa of ASP in JSP? Where can i write functions to be performed when:- 1)Application is started 2)Session is started 3)Session is stopped 4)Application is stopped Piyush
"A scientist is not person who gives right answers but a person who asks right questions"
2 and 3 can be managed using the javax.servlet.http.HttpServletListeners (Activation, binding etc) 1 and 4 are generally vendor specific. Generally you can register a class that gets started when the server starts, but how you do it and what that looks like changes between servers. Dave
Joined: Jun 13, 2002
Thnx, David for your help. "A scientist is not a person who gives right answers but is a person who asks right questions."
well, i think u can do 1) and 4) in init() and destroy() methods respectively!! bcoz when the servlet is deployed the first time, init() is called and when u r going to remove the application ie undeploy the servlet, destroy() will be called. i haven't tried out though! rgds Shashi
For 1) you could try javax.servlet.init() to initialize your webapp but preload the servlet first. You better add a first-time switch too in the ServletContext because that servlet instance may be replaced by the container (they can do that under certain conditions) and you don't want your entire webapp re-initialized whenever a new instance of that servlet enters service.
or one could use "MUCH TALKED ABOUT" - Filters.... -maulin.
Joined: Jun 13, 2002
Hi, Well, here is some info which could be useful. OC4J supports a file, globals.jsa, as a mechanism for implementing the JSP specification in a servlet 2.0 environment.Within any single Java virtual machine, you can use a globals.jsa file for each application (or, equivalently, for each servlet context).The globals.jsa file also provides a vehicle for global Java declarations and JSP directives across all JSP pages of an application. The syntax for global.jsa file is as given below:-
Hope, this is helpful to others.I found this very useful as I have moved from ASP to JSP and Im used to global.asa This is a part of document called JSP reference.It is available for download from oracle`s otn website under Oracle 9ias Containers for J2EE.Im using OC4J for my project, so it helps me out. Regards, Piyush