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
Joined: Aug 18, 2003
Posts: 146
posted
0
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
Joined: Oct 09, 2002
Posts: 294
posted
0
I think using filters is more appropriate approach. Listeners are something acting as passive components not changing a normal flow.
Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
nandkishor rao
Ranch Hand
Joined: May 24, 2006
Posts: 53
posted
0
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?