This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Cannot login the same user on two browser at the same time using Struts 2 application 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 » Frameworks » Struts
Bookmark "Cannot login the same user on two browser at the same time using Struts 2 application" Watch "Cannot login the same user on two browser at the same time using Struts 2 application" New topic
Author

Cannot login the same user on two browser at the same time using Struts 2 application

Sushant Gandhi
Greenhorn

Joined: Jun 24, 2013
Posts: 16
Hello everyone, I'm developing the struts 2 application, in that i want to develop such application in that at the same time the same user data can not use two browser for LOGIN, I'm trying to use the actioncontext for that but not success that code....please give me the code for such that application....Thank you in advance
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8834
    
    7

Sushant Gandhi wrote:.please give me the code for such that application.


That's not what we do here. We would be glad to help you work on your problem. What have you tried so far?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Sushant Gandhi
Greenhorn

Joined: Jun 24, 2013
Posts: 16
Joe Ess wrote:
Sushant Gandhi wrote:.please give me the code for such that application.


That's not what we do here. We would be glad to help you work on your problem. What have you tried so far?



Here the code:--

1) Action class:---




2) Fetching data from db class:-


3)Custom Interceptor class:--



4)web.xml:-


5)struts.xml:--



6)Login.jsp:--




please help me for prevent accessing same username and password at the same time with twice browser...
Sushant Gandhi
Greenhorn

Joined: Jun 24, 2013
Posts: 16
Please also tell me how can i pass the message to console when the session has been time out.....All code are display above...Please help me out of this
Karthik Jayachandran
Ranch Hand

Joined: Feb 18, 2009
Posts: 88

Sushant Gandhi wrote:pass the message to console when the session has been time out.

Use HttpSessionListener.


Please use Code tag to format your above code for better readability.
Sushant Gandhi
Greenhorn

Joined: Jun 24, 2013
Posts: 16
Karthik Jayachandran wrote:
Sushant Gandhi wrote:pass the message to console when the session has been time out.

Use HttpSessionListener.


Please use Code tag to format your above code for better readability.



No use dude.....its not working ....Tell me another option..
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

I've added the code tags for you. As far as the feature, it isn't a trivial thing that you can use a listener and be done with it.

You need to keep track of who is logged in. If you only have one clone, this can be done in memory. Otherwise, you need an external datastore like a database table.

When a user logs in, you need to decide what to do. If the user is already logged in, what do you want to do? You might automatically logout the old session. You might ask the user if they want to logout the old session.

Keep in mind that you don't always know when a user logs out. You might have to wait for session timeout. Hence the inclination to logout the old user.


[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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot login the same user on two browser at the same time using Struts 2 application
 
Similar Threads
Info regarding "_ERR_INVALID_COOKIE" code
HttpSession sharing between browser instances on same machine!
Multiple User Sessions getting Mixed
Spring security in same project by two separate user entities(Customer & User table)
Session need to be destroyed when browser closes