aspose file tools*
The moose likes Servlets and the fly likes How to restrict the number of users connecting to my website Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to restrict the number of users connecting to my website" Watch "How to restrict the number of users connecting to my website" New topic
Author

How to restrict the number of users connecting to my website

Harathi Rao
Ranch Hand

Joined: Oct 31, 2004
Posts: 42
I want to know if i can restrict my website to take only certain number of users at a given time.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31076
    
233

Harathi,
Welcome to JavaRanch!

I'm not sure what this has to do with JDBC. I'm going to move it to Servlets for now. If it ends up being about JDBC, someone can move it back.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31076
    
233

Harathi,
You could do something with SessionListeners to count the users as they log in. The tricky part is knowing when they logout. If they don't explicitly log out, you have to wait for the session to time out. So keep in mind that the user count is inflated.

Why do you want to restrict the number of users?
Harathi Rao
Ranch Hand

Joined: Oct 31, 2004
Posts: 42
So, there is no scope to say "stop the users from logging in", at the most what we can do is count the no. of users logged in ? is it all we can do?
Chris Dempsey
Greenhorn

Joined: Feb 24, 2004
Posts: 9
No, there really isn't anything that says "No more people can log in". Jeannne's suggestion would probably be the closest to what you want along with her warning about people just closing down a browser over logging out out the app proper.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Harathi Rao:
So, there is no scope to say "stop the users from logging in", at the most what we can do is count the no. of users logged in ? is it all we can do?


what else you want to do? and how you gonna do that?
is there any way out, other then counting the no. of logged in users?
[ November 01, 2004: Message edited by: adeel ansari ]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31076
    
233

Harathi,
With the count of the number of users logged in, you can display a "system is full" message instead of the login screen.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
That won't prevent bazillions of people from TRYING to log in. They'll hit your login page, you'll do some processing to count users and return a "system busy" message. That's going to chew up some CPU and resources on your server. If they keep banging the refresh button hoping to be the next lucky user to get past the busy page, they'll be eating up almost as many resources as regular users. Ouch! You might need a special gateway server that does nothing but reject login requests.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ajith Anand
Ranch Hand

Joined: Aug 30, 2004
Posts: 40
Originally posted by Stan James:
That won't prevent bazillions of people from TRYING to log in. They'll hit your login page, you'll do some processing to count users and return a "system busy" message. That's going to chew up some CPU and resources on your server. If they keep banging the refresh button hoping to be the next lucky user to get past the busy page, they'll be eating up almost as many resources as regular users. Ouch! You might need a special gateway server that does nothing but reject login requests.

A home page such as the one below and a session listener which would update an application attribute "logged.user.count" for each new session created should work.

homepage.jsp



I dont think a page such as the one above would need considerable resources on the server . I think Jeanne's approach would work....


LXI Technologies P Ltd
[url]www.lxisoft.com[/url]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31076
    
233

Stan,
There isn't anything you can do about users trying to log in. That's why it's hard to deal with denial of service attacks.
sawan parihar
Ranch Hand

Joined: Aug 24, 2004
Posts: 250
Hi ,
Implement an HttpSessionListener and follow what Ajith Anand has written. This will work.

Cheers


Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Stan James:
That won't prevent bazillions of people from TRYING to log in. They'll hit your login page, you'll do some processing to count users and return a "system busy" message. That's going to chew up some CPU and resources on your server. If they keep banging the refresh button hoping to be the next lucky user to get past the busy page, they'll be eating up almost as many resources as regular users. Ouch! You might need a special gateway server that does nothing but reject login requests.


Laughing out loud.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I re-read that last sentence and thought somebody might read it to suggest rejecting ALL login attempts. That would cut down your load fer sure.

Some of these techniques will work fine if you have an office of 50 people and you only want 75 logins. But a public web site can never predict the number of potential users - maybe you'll be mentioned on The Screen Savers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to restrict the number of users connecting to my website