• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to access Another servlet's Response Object  RSS feed

 
Oruganti Subrahmanyam
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My requirement is,

In my application., at login time., if any other person logs into the application with same username., then the first person has to get an alert whether to allow him or not..

i have controller as servlet.. And i wanted to know how to access other person's response object..(without having a request from him).

I started to do this using ServletContext., by putting the response object in ServletContext--setAttribute() to access it globally for all requests..

But i got IllegalStateException.. Please tell me a solution to solve this problem..

Thanx&Regards
Subrahmanyam
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure...but maybe you can store it in the session, and access the user's session. If you need to store a handle to the sessions of all the folks logged in, check out how to use a SessionListener:

http://java.sun.com/products/java-media/jmf/2.1.1/apidocs/javax/media/rtp/SessionListener.html

http://jakarta.apache.org/turbine/turbine/turbine-2.3.1/apidocs/org/apache/turbine/services/session/SessionListener.html
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is difficult to implement in HTTP which is a stateless enviromnent.

1.) You can't push a message to the person who is already logged in.
You would either need to have a polling frame on their page that refreshes periodically, looking for a message or implement a socket connection with an applet/flash app or something like that.

2.) Unless you go the applet route, you have no way of knowing if person one is still online. That person may have logged in and then moved on. The second person would be forced to wait until the first person's session times out. This is usually 30 minutes.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!