• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we restrict number of sessions through configuration(web.xml).

 
K Sanjeet
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

My first post and the first query. I want to know if there is anything in web.xml through which I can restrict the number of sessions.

I can only think of using the HttpSessionListener and restricting the number of sessions but I am not sure if there is any configuration tag available for web.xml to do it.

Thanks
Sanjeet
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
There is no entry in web.xml to restrict number of sessions in a JVM.
You need to do that programatically.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I can only think of using the HttpSessionListener and restricting the number of sessions


How do u do it?
 
K Sanjeet
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This

public class SessionCounter implements HttpSessionListener {
private static int sessionCount = 0;


public void sessionCreated() {
}
}
 
K Sanjeet
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

A psudo example. Something like this will let you control sessions.

public class SessionCounter implements HttpSessionListener {
private static int sessionCount = 0;


public void sessionCreated() {
if (SessionCount < 10) {
sessionCount++;
else
// forward the request to some jsp that will tell the user to wait OR some logic
}

public void sessionDestroyed() {
sessionCount--;
}
}

Do let me know if something is wrong with this.

Thanks
Sanjeet
 
Priya Jothi
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sanjeetz,

There is no way to control the number of sessions created through DD.
What r u trying to explain thru ur code?.It simply increments or decrements the sessioncount variable's value whenever session has been created or destroyed respectively.It has nothing to control the number of sessions created.Moreover sessionCreated() method is invoked only after the session is created.So u cant do it in this way.

hth..

Regards,
Priya.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic