File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes filters in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "filters in java" Watch "filters in java" New topic

filters in java

vinitha simon
Ranch Hand

Joined: Dec 13, 2007
Posts: 64
I would like to know how to redirect a filter to the request URL itself... I have tried

but, it does not seem to work.

Any help is appreciated.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20183

Why would you want to do that? It will call the same filters / servlet again, and again, and again, and again...

Anyway, moving to our servlet forum.

How To Ask Questions How To Answer Questions
vinitha simon
Ranch Hand

Joined: Dec 13, 2007
Posts: 64
Ok. I have a filter which checks if the user is already logged in. If the user has not logged in, it redirects the user to the login page, but, if the user is already logged in, I just want to be able to process the user's request ie, forward/redirect to the user specified url.

Any suggestions.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63534

You don't redirect in that case; you call the next resource in the filter chain. Any tutorial on filters will show you the correct pattern.

[Asking smart questions] [About Bear] [Books by Bear]
vinitha simon
Ranch Hand

Joined: Dec 13, 2007
Posts: 64
Thanks all ! I did chain it, and it works fine !
I agree. Here's the link:
subject: filters in java
It's not a secret anymore!