• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Redirection using a Listener

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic