Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Start

 
Piyush Daiya
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Piyush Daiya
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnx, David for your help.
"A scientist is not a person who gives right answers but is a person who asks right questions."
 
Shashi Kanta
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or one could use "MUCH TALKED ABOUT" - Filters....
-maulin.
 
Piyush Daiya
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:-

<event:application_OnStart>
</event:application_OnStart>
<event:application_OnEnd>
</event:application_OnEnd>
<event:session_OnStart>

</event:session_OnStart>
<event:session_OnEnd>
</event:session_OnEnd>

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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic