Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

servletcontextlistener

This is a discussion on servletcontextlistener within the Java forums, part of the Software Development category; wats the purpose of servletcontextlistener class...

Go Back   Geeks Talk > Software Development > Java
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Java Java related Issues and Problems

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-04-2009
Contributing Member
 
Join Date: Dec 2008
Location: Bangalore
Posts: 32
Thanks: 8
Thanked 2 Times in 2 Posts
joy_0007 is on a distinguished road
servletcontextlistener

wats the purpose of servletcontextlistener class
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-04-2009
Expert Member
 
Join Date: May 2009
Location: Bangalore
Posts: 989
Thanks: 155
Thanked 420 Times in 201 Posts
rijus is just really nicerijus is just really nicerijus is just really nicerijus is just really nicerijus is just really nice
Re: servletcontextlistener

Hi joy,


servletcontextlistener class handles notifications about changes to the servlet context of the web application that they are part of.


This can be explained as if someone is present on the server and dynamically informing us about the events that are occuring on the server.

There acquire need of listners.

Therefore, servletcontextlistner is helpful in informing about context initilazation and destruction.


Eg:


import javax.servlet.servletcontextlistener;
import javax.servlet.servletcontextevent;
import javax.servlet.*;

public class mylistener implements servletcontextlistener {
{

private servletcontext context = null;

/*this method is invoked when the web application has been removed and is no longer able to accept requests */

and...............

Public void contextdestroyed(servletcontextevent event)

{

//output a simple message to the server's console system.out.println("the simple web app. Has been removed");

this.context = null;
}

//this method is invoked when the web application is ready to service requests.

Public void contextinitialized(servletcontextevent event)

{
this.context = event.getservletcontext();

//output a simple message to the server's console system.out.println("the simple web app. Is ready");

} }


<web-app>
<listener>
<listener-class>
com.listeners.mycontextlistener
</listener-class>
</listener>
<servlet/>
<servlet-mapping/>
</web-app>



Thanks...

Riju.

Last edited by rijus; 06-04-2009 at 07:07 AM.
Reply With Quote
The Following User Says Thank You to rijus For This Useful Post:
Reply

  Geeks Talk > Software Development > Java

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 01:15 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved