Single Login Only in Java Studio Creator

Hi Guys,

Let's say i want to make my application to restrict all userId who already logged on cannot login anymore

What i did is once the login processiong i ll store in SessionBean

and ApplicationBean ( using Hashtable to store all other users as well )

There are few scenarion here:

1.

-. user "user1" logged on from his computer

-. another user using "user1" cannot login anymore from anywhere else since the information stored in ApplicationBean

-. user "user1" logged off

-. another user using "user1" can login since Session is invalidate and i remove the entry from my ApplicationBean

Above scenarion no problem.

The problem with scenarion below.

2

- user "user1" logged on from his computer

- another user using "user1" cannot login same as above

since the the information stored in ApplicationBean and validated against it before proceeding

- user "user1" close his window ( this cause the Session invalidate it self )

- BUT the user "user1" id is locked out forever since the data is still stored in the ApplicationBean unless the Application get restarted.

How do i resolve this?

Thanks in Advance.

[1240 byte] By [just_a_kid83] at [2007-11-26 9:37:17]
# 1

>2

> - user "user1" logged on from his computer

> - another user using "user1" cannot login same as

> above

> since the the information stored in

> ApplicationBean and validated against it before

> proceeding

> - user "user1" close his window ( this cause the

> Session invalidate it self )

> - BUT the user "user1" id is locked out forever

> since the data is still stored in the

> ApplicationBean unless the Application get

> restarted.

The interessting point is: "this cause the Session invalidate itself"

Actually this means all Beans with Session Scope e.g. SessionBean1 will be destroyed. When this happens in SessionBean1 the method destroy()

will be called. In this method you can delete the registration information in the application bean and it will work as desired.

To tune the application you will set the Session Timeout for the server to the desired value. I do not exactly know how to do this, but you'll find it in the documentation.

Have fun,

Juergen

bookon at 2007-7-7 0:30:28 > top of Java-index,Development Tools,Java Tools...
# 2

The app server reads the web.xml file and sets the application session timeout from that value. To put an entry into web.xml select View -> Files, open the projectname->web->WEB-INF->web.xml file. Select XML to edit directly and put this in:

<session-config>

<session-timeout>yourtimeoutvalue</session-timeout>

</session-config>

You can also set the timeout value in the appserver, but you'll have to check the docs as I believe the process is different for each server.

creonnoir at 2007-7-7 0:30:28 > top of Java-index,Development Tools,Java Tools...
# 3

Thanks guys , it works

What i did initially creating much more complicated method which will be invoked everytime the request coming to check whether the session is valid

Now what i did is just set the session timeout

and in the SessionBean destroy()

i will remove the entry from the Hashtable stored in ApplicationBean.

just_a_kid83 at 2007-7-7 0:30:28 > top of Java-index,Development Tools,Java Tools...