*
The moose likes Servlets and the fly likes Listening for events from different app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Listening for events from different app" Watch "Listening for events from different app" New topic
Author

Listening for events from different app

Maciej Majewski
Greenhorn

Joined: Sep 05, 2008
Posts: 5
Hi,

Is there a way to let's say deploy 2 application A and B on the web server and in application A listening for session events from application B?

If I setup a HttpSessionListener in A it will be listening only for events regarding application A.

What I want to achieve is that I already have an application which I can't modify. So I would like to implement another application which could capture session timout of this first application.

Thanks
Maciej
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

Maciej,
You can't. You need to change application B to add the listener or not implement the functionality.


[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
Maciej Majewski
Greenhorn

Joined: Sep 05, 2008
Posts: 5
There must some kind of a solution.

I was thinking about some kind of Global Session Listener or maybe implementing web filter which could intercept HTTP request and responses. But I couldn't google for anything meaningful.

Thanks
Maciej
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

Hi Maciej,

I'm not 100% sure if it's possible to track HTTP sessions from different web apps but I think it's not like Jeanne already said. And there are many good reasons why this shouldn't be possible.

Perhaps it would be easier to find a solution if you could tell us a little bit more what exactly you're trying to achieve

The first solution that comes to mind is to monitor your sessions in the same application A with the session listener. And than this listener could use another communication mechanism to interact with application B. Depending on what you're trying to do and other requirements you could think about socket connections, RMI or JMX to communicate between web appication A and B.

Marco
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4167
    
  21

Originally posted by Maciej Java:
There must some kind of a solution.

I was thinking about some kind of Global Session Listener or maybe implementing web filter which could intercept HTTP request and responses. But I couldn't google for anything meaningful.

Thanks
Maciej


No, sessions are application specific. So you have to attack it from the application B side, there is no global way of doing this.

A better question may be, why do you need access to application B's sessions? There may be a better way to do what you need by-passing the session objects themselves.


Steve
Maciej Majewski
Greenhorn

Joined: Sep 05, 2008
Posts: 5
But application B doesn't offer communication/interaction mechanisms.

The problem is that on session timeout app B displays login screen. However I'm using different way to login to app B that this screen. So I would like to deploy other app A which would intercept session timeout and redirect the user browser to proper page instead of this login screen.

Thanks
Maciej
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

Wouldn't it be possible to add a servlet/JSP to your application B which you could configure as an interception filter for the unwanted login screen in the web.xml descriptor and replace the login screen this way? This is just an idea. Unfortunately I don't know ad hoc if it's possible to add some servlets/JSPs to a web application if you don't have the source code (I guess you don't have it?!?) Perhaps this is an option for you...

Marco
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

"Maciej Java", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Originally posted by Maciej Java:
The problem is that on session timeout app B displays login screen. However I'm using different way to login to app B that this screen. So I would like to deploy other app A which would intercept session timeout and redirect the user browser to proper page instead of this login screen.
Why on earth do you need two apps for this? This problem has been long-solved using filters and the session. Why all the extra noise of a second application?
Maciej Majewski
Greenhorn

Joined: Sep 05, 2008
Posts: 5
Originally posted by Marco Ehrentreich:
Wouldn't it be possible to add a servlet/JSP to your application B which you could configure as an interception filter for the unwanted login screen in the web.xml descriptor and replace the login screen this way? This is just an idea. Unfortunately I don't know ad hoc if it's possible to add some servlets/JSPs to a web application if you don't have the source code (I guess you don't have it?!?) Perhaps this is an option for you...

Marco


Unfortunately I can't. App B is out of the box application bought by my company hosted on ISS and Sun Web Server which I can't touch.
What I can probably do is deploy some other application to this web server. And this other application should make some interception etc but from above answers this seems to be imposible.

However e.g. here http://3hq.eu/?16a I found sth. about Global servlet listeners.
Maciej Majewski
Greenhorn

Joined: Sep 05, 2008
Posts: 5
Originally posted by Bear Bibeault:
Why on earth do you need two apps for this? This problem has been long-solved using filters and the session. Why all the extra noise of a second application?


This was just an idea. If you read my previous post in this topic you will notice that I also mentioned Global Session Listeners and web filters.

However could you describe how filter could help in this kind of problem or just provide some link on the web?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Originally posted by Maciej Java:
Unfortunately I can't. App B is out of the box application bought by my company hosted on ISS and Sun Web Server which I can't touch.
Ah! That's the key to the puzzle. You are not going to be able to affect "app B" without the ability to make changes to it.

Imagine the security implications if you could!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

Originally posted by Maciej Java:
Unfortunately I can't. App B is out of the box application bought by my company hosted on ISS and Sun Web Server which I can't touch.
What I can probably do is deploy some other application to this web server. And this other application should make some interception etc but from above answers this seems to be imposible.

However e.g. here http://3hq.eu/?16a I found sth. about Global servlet listeners.

"global" servlet listeners still involve changing the app. Or rather having WebSphere (since it's an IBM link) change them on your behalf.

From that link:
To implement global listening, a listener is registered at the Web container level and is propagated to all of the installed and new Web applications.

This is changing the application you aren't "allowed" to change. The difference is that you aren't redeploying it.
 
 
subject: Listening for events from different app
 
Similar Threads
HttpSessionActivationListener when session moves from one vm to another.
Capturing/Consuming Alt+Tab combination under JFrame
Behaviour of distributed web application.
Q 8 from chap6 of Manning book
Sessions