• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to access Another servlet's Response Object

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic