wood burning stoves 2.0*
The moose likes Servlets and the fly likes HttpSessionListener doesn't listens to the event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

HttpSessionListener doesn't listens to the event

Arun Somasundaram
Ranch Hand

Joined: Jul 25, 2006
Posts: 63
Hi I am arun.The HttpSessionListener event is not firing up when a new session is created.The following program(ConcurrentUserTracker) increments the static variable "users" once when each session is created.
The servlet DispalyUsers displays the number of current active sessions in a webapplication.But the output I am always getting is 0(zero) eventhough more than 5 sessions accesses the practice(Web Application Name).See I have localarea network thats why I can able to access the webapplication simultaneously with 5 sessions.

Web Application name is practice


Here is the following code which implements the HttpSessionListener interface


ConcurrentUserTracker.java

Here is the servlet code which displays the number of active sessions.

DisplayUsers.java


and finally here is the listener element which I added to the deployment descriptor web.xml of the webapplication(practice)


I added this element immediately after the <web-app> element.

then the <servlet> and <servlet-mapping> elements are deployed as follows

<servlet>
<servlet-name>DisplayUsers</servlet-name>
<servlet-class>DisplayUsers</servlet-class>
</servlet>

after this

<servlet-mapping>
<servlet-name>DisplayUsers</servlet-name>
<url-pattern>/DisplayUsers</url-pattern>
</servlet-mapping>


After performing all this operations I opened my browser and executed the servlet I got the output as

Users:0


I fighted a lot to get the output as Users:1 or more but I don't.So please someone help me to resolve this problem

[ July 26, 2006: Message edited by: Arun Arun ]
[ July 26, 2006: Message edited by: Ben Souther ]

Arun.V.Somasundaram
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Javaranch tip:

If you are going to post more than a line or two of your code, wrap that
code in a set of UBB Code tags.
Doing so will help to preserve your code's indenting, making it easier to read.
If it is easier to read, more people will actaully read it and you will
stand a better chance of getting help with your question.



I've added them to your original post in the hopes that it will help you get a meaningful answer.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60739
    
  65

"Arun Arun",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Duplicate of:
http://www.coderanch.com/t/363070/Servlets/java/HttpSessionListener-doesn-listens-event

That one has answers so I'm closing this one.

Arun,
Please do not post your question mulitple times.
Doing so wastes people's time.

Had I noticed this earlier, I would have closed the other one.
This one has a much more meaningful subject line.
 
Consider Paul's rocket mass heater.
 
subject: HttpSessionListener doesn't listens to the event
 
Similar Threads
doubt in HTTPSessionListener implementation?
Servlet Listeners--not working
How HttpSessionActivationListener works?
HttpSessionListener doesn't listens to the event
setmaxInactiveInterval