Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirection using a Listener

 
vishwanath nadimpally
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
I am working on a small application and I am trying to figure out a correct way of handling a situation.

The requirement is when ever a jsp or web resource tries to access resources underneath a particular directory the request is redirected to a new URL which is entirely different and on a different server where the user is authenticated first.Some thing like a filter.

Say for example some code like this

in a jsp, and the request should be redirected to a page on a new server where the user is authenticated and then redirected to xyz.jsp.

I was thinking of a Listener where I could start the listener once the server starts and when ever there's some code like



the listener intercepts the request and forwards the request to a servlet where I build my URL and redirect the request.


Is it possible to do something like this? or is there something wrong with this implementation.Are there any easier solutions to this problem.

Now, I have never written Listener code before and this is a genuine question. So it might sound like a stupid question.
 
Saritha Penumudi
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can use ServletRequestListener to do this task. But I am not sure if this will be a good approach.
Or else you can use filters to do same.

I also want to know the best approach to do this.
 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think using filters is more appropriate approach. Listeners are something acting as passive components not changing a normal flow.
 
nandkishor rao
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can't you use a sendRedirect()method to forward the request to another app. server?Or do you also want to hold the previous request and response objects state also?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic