aspose file tools*
The moose likes Servlets and the fly likes Servlet Filter question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Filter question" Watch "Servlet Filter question" New topic
Author

Servlet Filter question

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

I am trying to validate users using a servlet filter. My problem is that if the user is validated then I am to execute the fc.doFilter(request, response) method but my problem is that the original request and the request in the fc.doFilter(request, response) are the same and I then go into a perpetual loop where by my servlet filter keeps getting executed again and again and again.... You can see my problem.

My understanding is that I need to change the URL in the request but the URL in the original request is what gets me to the web page so I'm not understanding how I can change the URL in the original request and still get to my web page? I've been working on this servlet for 5 days now and really need some help.

Any help/direction would be greatly appreciated. Thank you.

Here is my code:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Please take the time to choose an appropriate forum for your posts. This forum is for questions on general Java. For more information, please click this link ⇒ CarefullyChooseOneForum.

This post has been moved to a more appropriate forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

My apologies. I was told that my question was a purely java question. However, I just got my problem resolved.

BTW, what forum should it have gone under?

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Melinda Savoy wrote:My problem is that if the user is validated then I am to execute the fc.doFilter(request, response) method but my problem is that the original request and the request in the fc.doFilter(request, response) are the same and I then go into a perpetual loop where by my servlet filter keeps getting executed again and again and again.... You can see my problem.

Nope, don't see it. Following the filter chain does not cause the filter to be triggered again. The redirects will, however.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Melinda Savoy wrote:I was told that my question was a purely java question.
By whom?

However, I just got my problem resolved.
The polite thing to do would be to post the resolution so that any future members with a similar issue can benefit from it.

BTW, what forum should it have gone under?
Servlets.
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

The resolution I was given on another list server was to do this so as to resolve the perpetual loop is to modify the code for validation:



As I explained earlier that I experienced that if the original URL was the exact same as the request parameter in the fc.doFilter then the doFilter was just keep getting called unless the URI was different and that would break me out of this perpetual call of the doFilter method.

When I put in the OR value in the if statement above that solved my problem and I was able to get to the "next chain".

Regards.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Filter question
 
Similar Threads
redirect to port 443
New question on SERVLET filter
One more Servlet Filter question, please
JSF Filter prevent direct access certain page
Help - Problems with redirect in servlet filter in my JSF web app